Submission #102972

# Submission time Handle Problem Language Result Execution time Memory
102972 2019-03-28T09:35:13 Z hugo_pm Rice Hub (IOI11_ricehub) C++17
100 / 100
32 ms 1920 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long llg;

int besthub(int R, int L, int X[], long long B)
{
	int deb = 0, mid = 0, fin = 0;
	int rep = 1;
	llg cur = 0;
	while (fin+1 < R) {
		++fin;
		cur += (X[fin] - X[mid]);
		while (deb <= fin) {
			while (mid+1 <= fin) {
				llg delta = X[mid+1] - X[mid];
				llg gl = (mid-deb+1);
				llg gr = (fin-(mid+1)+1);
				assert(gl+gr == fin-deb+1);
				llg nc = cur + gl*delta - gr*delta;
				if (nc > cur) break;
				cur = nc;
				++mid;
			}
			if (cur <= B) {
				break;
			}
			cur -= (X[mid]-X[deb]);
			++deb;
		}
		rep = max(rep, fin-deb+1);
	}
	return rep;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 252 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 20 ms 1792 KB Output is correct
4 Correct 20 ms 1792 KB Output is correct
5 Correct 12 ms 872 KB Output is correct
6 Correct 9 ms 896 KB Output is correct
7 Correct 22 ms 1528 KB Output is correct
8 Correct 17 ms 1536 KB Output is correct
9 Correct 8 ms 768 KB Output is correct
10 Correct 11 ms 888 KB Output is correct
11 Correct 28 ms 1920 KB Output is correct
12 Correct 32 ms 1792 KB Output is correct
13 Correct 14 ms 888 KB Output is correct
14 Correct 10 ms 896 KB Output is correct
15 Correct 15 ms 1380 KB Output is correct
16 Correct 19 ms 1408 KB Output is correct
17 Correct 18 ms 1664 KB Output is correct
18 Correct 22 ms 1664 KB Output is correct
19 Correct 20 ms 1784 KB Output is correct
20 Correct 30 ms 1656 KB Output is correct