# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
69262 | 2018-08-20T10:38:49 Z | Bruteforceman | Ancient Books (IOI17_books) | C++11 | 2000 ms | 15296 KB |
#include "books.h" #include "bits/stdc++.h" using namespace std; long long minimum_walk(std::vector<int> p, int s) { bool good = true; for(int i = 0; i < p.size(); i++) { if(p[i] != i) { good = false; } } if(good) return 0; int l = 0; int r = p.size() - 1; long long ans = 0; while(l < p.size() && p[l] == l) { if(s == l) { ans += 2; ++s; } ++l; } while(r >= 0 && p[r] == r) { if(s == r) { ans += 2; --s; } --r; } for(int i = l; i < r; i++) { int go_left = 0; int go_right = 0; for(int j = l; j <= i; j++) { if(p[j] > i) { ++go_left; } } for(int j = i + 1; j <= r; j++) { if(p[j] < i+1) { ++go_right; } } assert(go_left == go_right); ans += max(2, go_left + go_right); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 3 ms | 392 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 488 KB | Output is correct |
8 | Correct | 2 ms | 524 KB | Output is correct |
9 | Correct | 3 ms | 524 KB | Output is correct |
10 | Correct | 2 ms | 524 KB | Output is correct |
11 | Correct | 2 ms | 536 KB | Output is correct |
12 | Correct | 3 ms | 536 KB | Output is correct |
13 | Correct | 2 ms | 536 KB | Output is correct |
14 | Correct | 2 ms | 536 KB | Output is correct |
15 | Correct | 3 ms | 536 KB | Output is correct |
16 | Correct | 2 ms | 536 KB | Output is correct |
17 | Correct | 2 ms | 536 KB | Output is correct |
18 | Correct | 3 ms | 536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 3 ms | 392 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 488 KB | Output is correct |
8 | Correct | 2 ms | 524 KB | Output is correct |
9 | Correct | 3 ms | 524 KB | Output is correct |
10 | Correct | 2 ms | 524 KB | Output is correct |
11 | Correct | 2 ms | 536 KB | Output is correct |
12 | Correct | 3 ms | 536 KB | Output is correct |
13 | Correct | 2 ms | 536 KB | Output is correct |
14 | Correct | 2 ms | 536 KB | Output is correct |
15 | Correct | 3 ms | 536 KB | Output is correct |
16 | Correct | 2 ms | 536 KB | Output is correct |
17 | Correct | 2 ms | 536 KB | Output is correct |
18 | Correct | 3 ms | 536 KB | Output is correct |
19 | Correct | 4 ms | 536 KB | Output is correct |
20 | Correct | 3 ms | 536 KB | Output is correct |
21 | Correct | 3 ms | 536 KB | Output is correct |
22 | Correct | 3 ms | 592 KB | Output is correct |
23 | Correct | 4 ms | 620 KB | Output is correct |
24 | Correct | 3 ms | 760 KB | Output is correct |
25 | Correct | 4 ms | 760 KB | Output is correct |
26 | Correct | 4 ms | 820 KB | Output is correct |
27 | Correct | 4 ms | 820 KB | Output is correct |
28 | Correct | 5 ms | 820 KB | Output is correct |
29 | Correct | 3 ms | 820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 3 ms | 392 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 488 KB | Output is correct |
8 | Correct | 2 ms | 524 KB | Output is correct |
9 | Correct | 3 ms | 524 KB | Output is correct |
10 | Correct | 2 ms | 524 KB | Output is correct |
11 | Correct | 2 ms | 536 KB | Output is correct |
12 | Correct | 3 ms | 536 KB | Output is correct |
13 | Correct | 2 ms | 536 KB | Output is correct |
14 | Correct | 2 ms | 536 KB | Output is correct |
15 | Correct | 3 ms | 536 KB | Output is correct |
16 | Correct | 2 ms | 536 KB | Output is correct |
17 | Correct | 2 ms | 536 KB | Output is correct |
18 | Correct | 3 ms | 536 KB | Output is correct |
19 | Correct | 4 ms | 536 KB | Output is correct |
20 | Correct | 3 ms | 536 KB | Output is correct |
21 | Correct | 3 ms | 536 KB | Output is correct |
22 | Correct | 3 ms | 592 KB | Output is correct |
23 | Correct | 4 ms | 620 KB | Output is correct |
24 | Correct | 3 ms | 760 KB | Output is correct |
25 | Correct | 4 ms | 760 KB | Output is correct |
26 | Correct | 4 ms | 820 KB | Output is correct |
27 | Correct | 4 ms | 820 KB | Output is correct |
28 | Correct | 5 ms | 820 KB | Output is correct |
29 | Correct | 3 ms | 820 KB | Output is correct |
30 | Execution timed out | 2067 ms | 15296 KB | Time limit exceeded |
31 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 15296 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 | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 392 KB | Output is correct |
4 | Correct | 3 ms | 392 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 488 KB | Output is correct |
7 | Correct | 2 ms | 488 KB | Output is correct |
8 | Correct | 2 ms | 524 KB | Output is correct |
9 | Correct | 3 ms | 524 KB | Output is correct |
10 | Correct | 2 ms | 524 KB | Output is correct |
11 | Correct | 2 ms | 536 KB | Output is correct |
12 | Correct | 3 ms | 536 KB | Output is correct |
13 | Correct | 2 ms | 536 KB | Output is correct |
14 | Correct | 2 ms | 536 KB | Output is correct |
15 | Correct | 3 ms | 536 KB | Output is correct |
16 | Correct | 2 ms | 536 KB | Output is correct |
17 | Correct | 2 ms | 536 KB | Output is correct |
18 | Correct | 3 ms | 536 KB | Output is correct |
19 | Correct | 4 ms | 536 KB | Output is correct |
20 | Correct | 3 ms | 536 KB | Output is correct |
21 | Correct | 3 ms | 536 KB | Output is correct |
22 | Correct | 3 ms | 592 KB | Output is correct |
23 | Correct | 4 ms | 620 KB | Output is correct |
24 | Correct | 3 ms | 760 KB | Output is correct |
25 | Correct | 4 ms | 760 KB | Output is correct |
26 | Correct | 4 ms | 820 KB | Output is correct |
27 | Correct | 4 ms | 820 KB | Output is correct |
28 | Correct | 5 ms | 820 KB | Output is correct |
29 | Correct | 3 ms | 820 KB | Output is correct |
30 | Execution timed out | 2067 ms | 15296 KB | Time limit exceeded |
31 | Halted | 0 ms | 0 KB | - |