# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
622632 | KoD | Ancient Books (IOI17_books) | C++17 | 209 ms | 21096 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>
using ll = long long;
using std::pair;
using std::vector;
ll minimum_walk(vector<int> P, int s) {
{
int l = 0, r = (int)P.size() - 1;
while (l < s and P[l] == l) {
l += 1;
}
while (r > s and P[r] == r) {
r -= 1;
}
P.erase(P.begin() + r + 1, P.end());
P.erase(P.begin(), P.begin() + l);
s -= l;
}
const int N = (int)P.size();
vector<char> seen(N);
vector<int> left(N), right(N);
ll ans = 0;
for (int i = 0; i < N; ++i) {
ans += std::abs(P[i] - i);
if (seen[i]) {
continue;
}
vector<int> cycle;
# | 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... |