제출 #171606

#제출 시각아이디문제언어결과실행 시간메모리
171606losmi247Arranging Shoes (IOI19_shoes)C++14
50 / 100
35 ms6648 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5+45; ll n,a[N]; ll count_swaps(vector <int> S){ n = S.size(); for(int i = 1; i <= n; i++){ a[i] = S[i-1]; } ll sol = 0; for(int i = 1; i <= n; i += 2){ ll poz = 0; for(int j = i+1; j <= n; j++){ if(a[i]+a[j] == 0){ poz = j; break; } } for(int j = poz-1; j > i; j--){ swap(a[j],a[j+1]); sol++; } if(a[i] > 0){ swap(a[i],a[i+1]); sol++; } } return sol; } /*int main(){ vector <int> v = {-2, 2, 2, -2, -2, 2}; cout << count_swaps(v) << endl; }*/
#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...