Submission #282359

#TimeUsernameProblemLanguageResultExecution timeMemory
282359GREGOIRELCArranging Shoes (IOI19_shoes)C++14
10 / 100
53 ms67704 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...