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 <queue>
#define pii pair <int, int>
using namespace std;
long long count_swaps(vector<int> s){
int n = (int)s.size();
for(int i = 0; i < n; i++){
if(s[i] < 0){
s[i] = -1;
}else{
s[i] = +1;
}
}
long long ans = 0;
queue <pii> St;
for(int i = 0; i < n; i++){
if(!St.empty() && St.front().first == -s[i]){
ans += ((int)St.size() - (St.front().first < s[i]));
St.pop();
}else{
St.push({s[i], i});
}
}
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... |