제출 #226075

#제출 시각아이디문제언어결과실행 시간메모리
226075AaronNaiduArranging Shoes (IOI19_shoes)C++14
85 / 100
38 ms1920 KiB
#include <bits/stdc++.h> using namespace std; int n; long long counter = 0; long long count_swaps(vector<int> s) { n = s.size()/2; if (n > 2500) { n = s.size()/2; int minusPos = 0; for (int i = 0; i < 2 * n; i++) { if (s[i] < 0) { counter += abs(i - minusPos); minusPos += 2; } } return counter; } for (int i = 0; i < n; i++) { int x = -s[2 * i]; int pos = -1; for (int j = 2 * i + 1; j < 2 * n; j++) { if (s[j] == x) { pos = j; break; } } for (int j = pos; j > 2 * i + 1; j--) { swap(s[j], s[j-1]); counter++; } if (x < 0) { counter++; } //cout << "After pair " << i << " count is " << counter << "\n"; } return counter; }
#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...