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 "shoes.h"
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int N=1e5+10;
int n;
long long count_swaps(vector<int> s) {
n=s.size();
vi pos;
FOR(i, 0, n) if(s[i]<0) pos.pb(i);
ll ans=0; int in=n-2;
for(int i=n/2-1; i>=0; i--){
ans+=abs(in-pos[i]);
in-=2;
// cout << pos[i] << " " << in << endl;
}
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... |