Submission #54706

# Submission time Handle Problem Language Result Execution time Memory
54706 2018-07-04T16:42:55 Z fallingstar Ancient Books (IOI17_books) C++14
50 / 100
202 ms 103112 KB
#include "books.h"
#include <cassert>
#include <algorithm>

#define long long long

using namespace std;

long minimum_walk(std::vector<int> p, int s) {
    assert(s == 0);
	int n = p.size();
    while (n > 0 && p[n - 1] == n - 1) --n;
    int mx = 0; long ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (i > 0 && mx < i) ans += 2;
        mx = max(mx, p[i]);
        ans += abs(i - p[i]);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 680 KB Output is correct
17 Correct 2 ms 680 KB Output is correct
18 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 680 KB Output is correct
17 Correct 2 ms 680 KB Output is correct
18 Correct 2 ms 680 KB Output is correct
19 Correct 2 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 680 KB Output is correct
22 Correct 2 ms 680 KB Output is correct
23 Correct 2 ms 680 KB Output is correct
24 Correct 2 ms 680 KB Output is correct
25 Correct 2 ms 680 KB Output is correct
26 Correct 2 ms 680 KB Output is correct
27 Correct 2 ms 680 KB Output is correct
28 Correct 2 ms 680 KB Output is correct
29 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 680 KB Output is correct
17 Correct 2 ms 680 KB Output is correct
18 Correct 2 ms 680 KB Output is correct
19 Correct 2 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 680 KB Output is correct
22 Correct 2 ms 680 KB Output is correct
23 Correct 2 ms 680 KB Output is correct
24 Correct 2 ms 680 KB Output is correct
25 Correct 2 ms 680 KB Output is correct
26 Correct 2 ms 680 KB Output is correct
27 Correct 2 ms 680 KB Output is correct
28 Correct 2 ms 680 KB Output is correct
29 Correct 2 ms 680 KB Output is correct
30 Correct 171 ms 15296 KB Output is correct
31 Correct 157 ms 22052 KB Output is correct
32 Correct 137 ms 28824 KB Output is correct
33 Correct 135 ms 35656 KB Output is correct
34 Correct 138 ms 42484 KB Output is correct
35 Correct 153 ms 48988 KB Output is correct
36 Correct 139 ms 55860 KB Output is correct
37 Correct 141 ms 62464 KB Output is correct
38 Correct 145 ms 69240 KB Output is correct
39 Correct 152 ms 75984 KB Output is correct
40 Correct 158 ms 82772 KB Output is correct
41 Correct 202 ms 89516 KB Output is correct
42 Correct 173 ms 96200 KB Output is correct
43 Correct 142 ms 103112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 103112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 680 KB Output is correct
17 Correct 2 ms 680 KB Output is correct
18 Correct 2 ms 680 KB Output is correct
19 Correct 2 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 680 KB Output is correct
22 Correct 2 ms 680 KB Output is correct
23 Correct 2 ms 680 KB Output is correct
24 Correct 2 ms 680 KB Output is correct
25 Correct 2 ms 680 KB Output is correct
26 Correct 2 ms 680 KB Output is correct
27 Correct 2 ms 680 KB Output is correct
28 Correct 2 ms 680 KB Output is correct
29 Correct 2 ms 680 KB Output is correct
30 Correct 171 ms 15296 KB Output is correct
31 Correct 157 ms 22052 KB Output is correct
32 Correct 137 ms 28824 KB Output is correct
33 Correct 135 ms 35656 KB Output is correct
34 Correct 138 ms 42484 KB Output is correct
35 Correct 153 ms 48988 KB Output is correct
36 Correct 139 ms 55860 KB Output is correct
37 Correct 141 ms 62464 KB Output is correct
38 Correct 145 ms 69240 KB Output is correct
39 Correct 152 ms 75984 KB Output is correct
40 Correct 158 ms 82772 KB Output is correct
41 Correct 202 ms 89516 KB Output is correct
42 Correct 173 ms 96200 KB Output is correct
43 Correct 142 ms 103112 KB Output is correct
44 Runtime error 3 ms 103112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
45 Halted 0 ms 0 KB -