제출 #294651

#제출 시각아이디문제언어결과실행 시간메모리
294651mode149256Arranging Shoes (IOI19_shoes)C++14
50 / 100
1094 ms3072 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; ll count_swaps(vi s) { ll ats = 0; int N = (int)s.size(); for (int i = 0; i < N; ++i) { // if (s[i] > 0) { // int nx = i + 1; // while (s[nx] > 0) nx++; // int val = s[nx]; // s.erase(s.begin() + nx); // s.insert(s.begin() + i, val); // ats += nx - i; // } // s[i] < 0 int nx = i + 1; while (s[nx] + s[i] != 0) nx++; ats += nx - (i + 1); s.erase(s.begin() + nx); s.insert(s.begin() + i + 1, -s[i]); if (s[i] > s[i + 1]) ats++; i++; } return ats; }
#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...