Codeforces 1213B. Bad Prices Solution

Solve in C:

  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE
  4. ///Islamic University,Bangladesh
  5. #include<iostream>
  6. using namespace std;
  7. int main(){
  8. long long int i,ar[150009]={0},t,v,n;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int r=0;
  13. cin>>n;
  14. for(i=0;i<n;i++)
  15. {
  16. cin>>ar[i];
  17. }
  18. v=ar[n-1];
  19. for(i=n-1;i>=0;i--)
  20. {
  21. if(v<ar[i])
  22. r++;
  23. else
  24. v=ar[i];
  25. }
  26. cout<<r<<endl;
  27. } 
  28.  
  29. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.