제출 #1258916

#제출 시각아이디문제언어결과실행 시간메모리
1258916kawhietArranging Shoes (IOI19_shoes)C++20
50 / 100
1093 ms1864 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;

long long count_swaps(vector<int> a) {
    int n = a.size();
    long long res = 0;
    for (int i = 0; i < n; i += 2) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] == -a[j]) {
                for (int k = j - 1; k >= i + 1; k--) {
                    res++;
                    swap(a[k], a[k + 1]);
                }
                break;
            }
        }
        if (a[i] >= 0) {
            res++;
            swap(a[i], a[i + 1]);
        }
    }
    return res;
}
#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...