Advertisement
Saleh127

UVA 13082

Jun 1st, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13.  
  14.  
  15.  
  16. ll n,m,i,j,k,l=0;
  17.  
  18. cin>>n;
  19.  
  20. ll a[n+4],b[n+4];
  21.  
  22. for(i=0; i<n; i++)
  23. {
  24. cin>>a[i];
  25.  
  26. b[i]=a[i];
  27. }
  28.  
  29. sort(b,b+n);
  30.  
  31.  
  32. i=j=0;
  33.  
  34. while(i<n)
  35. {
  36. if(a[i]==b[j])
  37. {
  38. i++;
  39. j++;
  40. }
  41. else
  42. {
  43. l++;
  44. i++;
  45. }
  46. }
  47.  
  48. cout<<"Case "<<cs<<": "<<l<<endl;
  49. }
  50.  
  51. return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement