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"
using namespace std;
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
set<int> L, R;
long long count_swaps(std::vector<int> s) {
int n = (int)s.size();
for(int i=0;i<(int)s.size();i++){
if(s[i] < 0)L.insert(i);
else R.insert(i);
}
long long ans = 0;
for(int i=0;i<n;i++){
if(i%2){
ans += max(0, *(R.begin()) - i);
R.erase(R.begin());
}
else{
ans += max(0, *(L.begin()) - i);
L.erase(L.begin());
}
}
return ans;
}
# | 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... |