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 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

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

Powered by Blogger.