# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289275 | Touubs | Ancient Books (IOI17_books) | C++17 | 174 ms | 9080 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "books.h"
#include <bits/stdc++.h>
long long minimum_walk(std::vector<int> p, int s) {
std::vector<bool> visited(p.size());
long long res = 0;
int maxVis = 0;
for (int i = 0; i < p.size(); i++) {
if (maxVis < i) res+=2;
res += abs(p[i] - i);
maxVis = std::max(maxVis, p[i]);
}
for (int i = p.size() - 1; i > 0 && p[i] == i; i--) res-=2;
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |