Submission #586570

#TimeUsernameProblemLanguageResultExecution timeMemory
586570VanillaAncient Books (IOI17_books)C++17
0 / 100
4 ms304 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; typedef long long int64; int64 minimum_walk(vector<int> a, int s) { int n = a.size(); int64 rs = 0; for (int i = 0; i < n; i++){ int sp = 0; for (int j = 0; j < n - i - 1; j++){ if (a[j] > a[j + 1]) { swap(a[j], a[j + 1]); sp = j; } } for (int j = sp; j >= 1; j--){ if (a[j] > a[j-1]) { swap(a[j], a[j - 1]); } } if (sp == 0) break; rs+= sp * 2; } return rs; }
#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...