Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- long n;
- long count;
- void check(long i,long j,long a[])
- {
- cout<<"checking "<<i<<" "<<j<<"\n";
- if(i==n-1)
- {
- }
- else if(i==j)
- check(i+1,n-1,a);
- else if(a[i]>a[j])
- {
- // cout<<i<<" "<<j<<"\n";
- ::count++;
- check(i,j-1,a);
- }
- else
- check(i,j-1,a);
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- cin>>n;
- long a[n];
- long i;
- ::count=0;
- for(i=0;i<n;i++)
- cin>>a[i];
- check(0,n-1,a);
- cout<<::count<<"\n";
- }
- }
Add Comment
Please, Sign In to add comment