제출 #154033

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