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

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.