Submission #165614

# Submission time Handle Problem Language Result Execution time Memory
165614 2019-11-27T18:09:23 Z johutha Ancient Books (IOI17_books) C++14
50 / 100
631 ms 20444 KB
#include "books.h"
#include <vector>
#include <iostream>
#include <cmath>
#include <set>

#define int long long

using namespace std;

int minimum_walk(vector<signed> p, signed s)
{
	int n = p.size();
	int res = 0;

	for (int i = 0; i < n; i++)
	{
		res += abs(i - p[i]);
	}

	set<int> numbers;

	vector<bool> used(n - 1, 0);

	for (int i = 0; i < n; i++)
	{
		if (numbers.size() > 0 && i > 0)
		{
			used[i - 1] = true;
		}
		numbers.erase(i);
		if (p[i] > i) numbers.insert(p[i]);
	}

	bool nont = false;

	for (int i = n - 1; i > 0; i--)
	{
		if (p[i] != i) nont = true;
		if (!nont) used[i - 1] = true;
	}

	for (int i = 0; i < n - 1; i++)
	{
		if (!used[i]) res += 2;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 392 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 392 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 508 KB Output is correct
30 Correct 631 ms 20412 KB Output is correct
31 Correct 613 ms 20444 KB Output is correct
32 Correct 148 ms 8540 KB Output is correct
33 Correct 175 ms 8544 KB Output is correct
34 Correct 167 ms 8580 KB Output is correct
35 Correct 176 ms 8568 KB Output is correct
36 Correct 198 ms 8568 KB Output is correct
37 Correct 245 ms 8548 KB Output is correct
38 Correct 264 ms 8696 KB Output is correct
39 Correct 265 ms 8696 KB Output is correct
40 Correct 313 ms 9080 KB Output is correct
41 Correct 471 ms 14560 KB Output is correct
42 Correct 403 ms 13560 KB Output is correct
43 Correct 188 ms 8824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 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 252 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 392 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 508 KB Output is correct
30 Correct 631 ms 20412 KB Output is correct
31 Correct 613 ms 20444 KB Output is correct
32 Correct 148 ms 8540 KB Output is correct
33 Correct 175 ms 8544 KB Output is correct
34 Correct 167 ms 8580 KB Output is correct
35 Correct 176 ms 8568 KB Output is correct
36 Correct 198 ms 8568 KB Output is correct
37 Correct 245 ms 8548 KB Output is correct
38 Correct 264 ms 8696 KB Output is correct
39 Correct 265 ms 8696 KB Output is correct
40 Correct 313 ms 9080 KB Output is correct
41 Correct 471 ms 14560 KB Output is correct
42 Correct 403 ms 13560 KB Output is correct
43 Correct 188 ms 8824 KB Output is correct
44 Incorrect 2 ms 376 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
45 Halted 0 ms 0 KB -