This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "shoes.h"
#define rep(i,a,b) for(int i=a; i<b; i++)
#define long long long
using namespace std;
long count_swaps(vector<int> arr){
int N=arr.size();
int total=0;
for (int i = 0; i < N; ++i)
{
if(arr[i]==0) continue;
int free=0;
int end=-1;
rep(j,i+1,N){
if(arr[j]==-arr[i]){
end=j; break;
}
if(arr[j]==0) free++;
}
arr[end]=0;
if(arr[i]<0) total--;
total+=end-i;
}
return total;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |