Submission #418257

# Submission time Handle Problem Language Result Execution time Memory
418257 2021-06-05T08:49:19 Z Azimjon Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 1740 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int besthub(int R, int L, int X[], long long B) {
	auto cost = [&](int x, int y) { return abs(X[x] - X[y]); };

	int ans = -1;

	for (int i = 0; i < R; i++) {
		int cans = 0;
		long long cb = B;

		int l, r;
		l = i;
		r = i + 1;

		while (1) {
			int t;
			if (l == -1 && r != R)
				t = r++;
			else if (r == R && l != -1)
				t = l--;
			else if (cost(i, l) < cost(i, r))
				t = l--;
			else
				t = r++;

			if (cb - cost(i, t) >= 0) {
				cb -= cost(i, t);
				cans++;
			} else {
				break;
			}

			if (l == -1 && r == R)
				break;
		}

		ans = max(cans, ans);
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 220 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 204 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 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 2 ms 316 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 3 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 4 ms 204 KB Output is correct
18 Correct 3 ms 204 KB Output is correct
19 Correct 5 ms 204 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 4 ms 312 KB Output is correct
22 Correct 4 ms 332 KB Output is correct
23 Correct 67 ms 332 KB Output is correct
24 Correct 63 ms 332 KB Output is correct
25 Correct 115 ms 348 KB Output is correct
26 Correct 116 ms 344 KB Output is correct
27 Correct 41 ms 316 KB Output is correct
28 Correct 36 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 460 KB Output is correct
2 Correct 7 ms 460 KB Output is correct
3 Execution timed out 1084 ms 1740 KB Time limit exceeded
4 Halted 0 ms 0 KB -