# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1144599 | crispxx | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "shoes.h"
#include "grader.cpp"
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define nl '\n'
long long count_swaps(vector<int> s) {
int n = s.size();
long long ans = 0;
for(int i = 0; i < n; i++) {
if(i % 2 != (s[i] > 0)) {
int k = -1;
for(int j = i; j < n; j++) {
if(s[j] == -s[i]) {
k = j;
break;
}
}
for(int j = k; j > i; j--) {
swap(s[j], s[j - 1]);
}
ans += k - i;
}
}
return ans;
}