Submission #378446

# Submission time Handle Problem Language Result Execution time Memory
378446 2021-03-16T19:49:16 Z rainboy Gap (APIO16_gap) C
100 / 100
61 ms 1260 KB
#include "gap.h"

#define A	1000000000000000000

long long max(long long a, long long b) { return a > b ? a : b; }

long long findGap(int t, int n) {
	long long ans;

	if (t == 1) {
		long long l, r;
		int i;

		MinMax(0, A, &l, &r);
		ans = 0;
		for (i = 0; i < (n - 1) / 2; i++) {
			long long l_, r_;

			MinMax(l + 1, r - 1, &l_, &r_);
			ans = max(ans, max(l_ - l, r - r_));
			l = l_, r = r_;
		}
		if (n % 2 == 0)
			ans = max(ans, r - l);
	} else {
		long long lower, upper, b, a, a_, l, r;

		MinMax(0, A, &lower, &upper);
		b = (upper - lower + n - 2) / (n - 1) + 1;
		ans = b - 1, a_ = -1;
		for (a = lower; a <= upper; a += b) {
			MinMax(a, a + b - 1, &l, &r);
			if (a_ == -1)
				a_ = r;
			else if (r != -1)
				ans = max(ans, l - a_), a_ = r;
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 11 ms 492 KB Output is correct
17 Correct 10 ms 492 KB Output is correct
18 Correct 11 ms 768 KB Output is correct
19 Correct 11 ms 492 KB Output is correct
20 Correct 8 ms 512 KB Output is correct
21 Correct 42 ms 1260 KB Output is correct
22 Correct 42 ms 1132 KB Output is correct
23 Correct 42 ms 1132 KB Output is correct
24 Correct 42 ms 1132 KB Output is correct
25 Correct 37 ms 1132 KB Output is correct
26 Correct 41 ms 1140 KB Output is correct
27 Correct 43 ms 1132 KB Output is correct
28 Correct 42 ms 1156 KB Output is correct
29 Correct 41 ms 1132 KB Output is correct
30 Correct 34 ms 1132 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 268 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 16 ms 492 KB Output is correct
17 Correct 15 ms 492 KB Output is correct
18 Correct 14 ms 492 KB Output is correct
19 Correct 14 ms 492 KB Output is correct
20 Correct 7 ms 492 KB Output is correct
21 Correct 59 ms 1132 KB Output is correct
22 Correct 58 ms 1132 KB Output is correct
23 Correct 58 ms 1228 KB Output is correct
24 Correct 61 ms 1132 KB Output is correct
25 Correct 55 ms 1132 KB Output is correct
26 Correct 59 ms 1132 KB Output is correct
27 Correct 60 ms 1068 KB Output is correct
28 Correct 58 ms 1260 KB Output is correct
29 Correct 60 ms 1260 KB Output is correct
30 Correct 31 ms 1132 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct