Guest User

Untitled

a guest
Dec 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. long n;
  6. long count;
  7.  
  8. void check(long i,long j,long a[])
  9. {
  10. cout<<"checking "<<i<<" "<<j<<"\n";
  11. if(i==n-1)
  12. {
  13. }
  14. else if(i==j)
  15. check(i+1,n-1,a);
  16. else if(a[i]>a[j])
  17. {
  18. // cout<<i<<" "<<j<<"\n";
  19. ::count++;
  20. check(i,j-1,a);
  21. }
  22. else
  23. check(i,j-1,a);
  24. }
  25.  
  26. int main()
  27. {
  28. int t;
  29. cin>>t;
  30. while(t--)
  31. {
  32. cin>>n;
  33. long a[n];
  34. long i;
  35. ::count=0;
  36. for(i=0;i<n;i++)
  37. cin>>a[i];
  38. check(0,n-1,a);
  39. cout<<::count<<"\n";
  40. }
  41. }
Add Comment
Please, Sign In to add comment