Submission #1056997

#TimeUsernameProblemLanguageResultExecution timeMemory
1056997phoenixAncient Books (IOI17_books)C++17
12 / 100
1 ms348 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; long long minimum_walk(vector<int> p, int s) { int n = (int)p.size(); long long sum = 0; for (int i = 0; i < n; i++) sum += abs(p[i] - i); int l = n - 1; while (l && p[l] == l) l--; vector<int> suf = p; for (int i = n - 2; i >= 0; i--) suf[i] = min(suf[i], suf[i + 1]); while (suf[l] < l) l = suf[l]; return sum + 2 * l; }
#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...