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 <cmath>
#include <iostream>
#include <queue>
using namespace std;
const int MAX_SHOES = 1e5 + 1;
int lstType[MAX_SHOES];
queue<int> enCours[MAX_SHOES];
long long count_swaps(vector<int> s)
{
int N = (int)s.size();
long long result = 0;
for(int curShoes = 0; curShoes < N; curShoes++)
{
int taille = abs(s[curShoes]);
int tp = abs(s[curShoes]) / s[curShoes];
if(enCours[taille].empty())
{
enCours[taille].push(curShoes);
lstType[taille] = tp;
}
else
{
if(lstType[taille] == tp)
{
enCours[taille].push(curShoes);
}
else
{
result += curShoes - enCours[taille].front();
enCours[taille].pop();
if(tp == 1)
{
result--;
}
}
}
}
return result;
}
# | 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... |