Submission #1323954

#TimeUsernameProblemLanguageResultExecution timeMemory
1323954aritro_Arranging Shoes (IOI19_shoes)C++20
50 / 100
1095 ms1948 KiB
//#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back

ll count_swaps(std::vector<int> a){
    int n=a.size();
    ll l=0,r=0;
    ll ans=0;
    while(l<n){
 	    r++;
 	    int k=-1*a[l];
 	    if(k==a[r]){
 		    ans+=r-l-1;
 		    for(int i=r;i>l+1;i--) swap(a[i],a[i-1]);
 			if(a[l]>0){
 				ans++;
 				swap(a[l],a[l+1]);
 			}
 			l+=2;
 		    r=l;
 		}
 	}
 	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...