Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #define MAXT 100005
- using namespace std;
- int main(){
- int n;
- scanf("%d",&n);
- int A[MAXT];
- for(int i = 0;i<n;i++) scanf("%d",&A[i]);
- int resp=0;
- int B[MAXT];
- int tamb = 0;
- B[0] = A[0];
- for(int i = 0;i<n;i++){
- tamb++;
- for(int j = tamb;j>=1;j--){
- if(A[i] < B[j]){
- B[j+1] = B[j];
- resp++;
- }
- if(A[i] > B[j]){
- B[j+1] = A[i];
- break;
- }
- }
- }
- printf("%d\n",resp);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement