Submission #431564

# Submission time Handle Problem Language Result Execution time Memory
431564 2021-06-17T13:04:44 Z rainboy Ancient Books (IOI17_books) C++
50 / 100
181 ms 18772 KB
#include "books.h"

using namespace std;

const int N = 1000000;

typedef vector<int> vi;

int dd[N];

long long minimum_walk(vi pp, int s) {
	int n = pp.size(), i;
	long long ans;

	ans = 0;
	for (i = 0; i < n; i++)
		if (i < pp[i])
			ans += pp[i] - i, dd[i]++, dd[pp[i]]--;
		else if (i > pp[i])
			ans += i - pp[i], dd[pp[i]]++, dd[i]--;
	for (i = 1; i < n - 1; i++)
		dd[i] += dd[i - 1];
	i = n - 1;
	while (i >= 0 && pp[i] == i)
		i--;
	for (i--; i >= 0; i--)
		if (dd[i] == 0)
			ans += 2;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 166 ms 18660 KB Output is correct
31 Correct 172 ms 18772 KB Output is correct
32 Correct 143 ms 18724 KB Output is correct
33 Correct 161 ms 18656 KB Output is correct
34 Correct 144 ms 18660 KB Output is correct
35 Correct 146 ms 18656 KB Output is correct
36 Correct 156 ms 18656 KB Output is correct
37 Correct 177 ms 18660 KB Output is correct
38 Correct 140 ms 18660 KB Output is correct
39 Correct 144 ms 18712 KB Output is correct
40 Correct 181 ms 18660 KB Output is correct
41 Correct 168 ms 18656 KB Output is correct
42 Correct 159 ms 18652 KB Output is correct
43 Correct 168 ms 18660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 292 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 166 ms 18660 KB Output is correct
31 Correct 172 ms 18772 KB Output is correct
32 Correct 143 ms 18724 KB Output is correct
33 Correct 161 ms 18656 KB Output is correct
34 Correct 144 ms 18660 KB Output is correct
35 Correct 146 ms 18656 KB Output is correct
36 Correct 156 ms 18656 KB Output is correct
37 Correct 177 ms 18660 KB Output is correct
38 Correct 140 ms 18660 KB Output is correct
39 Correct 144 ms 18712 KB Output is correct
40 Correct 181 ms 18660 KB Output is correct
41 Correct 168 ms 18656 KB Output is correct
42 Correct 159 ms 18652 KB Output is correct
43 Correct 168 ms 18660 KB Output is correct
44 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
45 Halted 0 ms 0 KB -