제출 #1011674

#제출 시각아이디문제언어결과실행 시간메모리
1011674u_suck_oArranging Shoes (IOI19_shoes)C++17
45 / 100
19 ms3260 KiB
#include "bits/stdc++.h" #include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { long long ans = 0; long long n = s.size()/2; int p1 = 1, p2 = 1; for (int i = 0; i < 2*n; i++) { p1 = max(i+1, p1); p2 = max(i+1, p2); if (i % 2 == 0) { if (s[i] < 0) continue; while (s[p1] > 0) p1++; swap(s[i], s[p1]); ans += p1 - i; } if (i % 2 == 1) { if (s[i] > 0) continue; while (s[p2] < 0) p2++; swap(s[i], s[p2]); ans += p2 - 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...