Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. #define MAXT 100005
  4. using namespace std;
  5.  
  6. int main(){
  7. int n;
  8. scanf("%d",&n);
  9.  
  10. int A[MAXT];
  11. for(int i = 0;i<n;i++) scanf("%d",&A[i]);
  12.  
  13. int resp=0;
  14. int B[MAXT];
  15. int tamb = 0;
  16. B[0] = A[0];
  17.  
  18. for(int i = 0;i<n;i++){
  19. tamb++;
  20. for(int j = tamb;j>=1;j--){
  21. if(A[i] < B[j]){
  22. B[j+1] = B[j];
  23. resp++;
  24. }
  25. if(A[i] > B[j]){
  26. B[j+1] = A[i];
  27. break;
  28. }
  29. }
  30. }
  31.  
  32. printf("%d\n",resp);
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement