제출 #867399

#제출 시각아이디문제언어결과실행 시간메모리
867399lolismekArranging Shoes (IOI19_shoes)C++14
45 / 100
22 ms4020 KiB
#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 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...