# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289301 | 2020-09-02T14:22:56 Z | Touubs | Ancient Books (IOI17_books) | C++17 | 1 ms | 256 KB |
#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; int i; for (i = 0; i < p.size() && p[i] == i && i < s; i++); maxVis = i; for (; i < p.size(); i++) { if (maxVis < i && p[i] != i) { res+=2 * (i - maxVis); maxVis = std::max(maxVis, p[i]); } else if (maxVis >= i) { maxVis = std::max(maxVis, p[i]); } res += abs(p[i] - i); } for (int i = p.size() - 1; p[i] == i && i >= s; res -= 2, i--); return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '3304', found: '2744' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | 3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 | Halted | 0 ms | 0 KB | - |