Submission #143782

#TimeUsernameProblemLanguageResultExecution timeMemory
143782jh05013Arranging Shoes (IOI19_shoes)C++17
10 / 100
1044 ms2040 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size(); long long ans = 0; for(int i=0; i<n; i++){ int j = -999; if(i%2 == 0){ for(j=i; j<n; j++) if(s[j] < 0) break; } else{ for(j=i; j<n; j++) if(s[j] == -s[i-1]) break; } for(int k=j-1; k>=i; k--) swap(s[k], s[k+1]), ans++; } return ans; }
#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...