Submission #351904

# Submission time Handle Problem Language Result Execution time Memory
351904 2021-01-20T09:22:30 Z two_sides Gap (APIO16_gap) C++17
100 / 100
59 ms 1312 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

long long findGap(int t, int n) {
	long long lo, hi, res;
	MinMax(0, 1000000000000000000ll, &lo, &hi);
	if (t == 1) {
		res = 0;
		for (int i = 1; i < (n + 1) / 2; i++) {
			long long mn, mx;
			MinMax(lo + 1, hi - 1, &mn, &mx);
			res = max(res, mn - lo);
			res = max(res, hi - mx);
			lo = mn; hi = mx;
		}
		res = max(res, hi - lo);
		return res;
	}
	else {
		res = (hi - lo - 1) / (n - 1) + 1;
		long long step = res, pre = lo;
		while (lo < hi) {
			long long mn, mx;
			MinMax(lo, lo + res - 1, &mn, &mx);
			lo += res;
			if (mn == -1) continue;
			res = max(res, mn - pre); pre = mx;
		}
		return res;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:23:13: warning: unused variable 'step' [-Wunused-variable]
   23 |   long long step = res, pre = lo;
      |             ^~~~
# 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 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 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 11 ms 696 KB Output is correct
18 Correct 12 ms 492 KB Output is correct
19 Correct 12 ms 492 KB Output is correct
20 Correct 10 ms 492 KB Output is correct
21 Correct 51 ms 1060 KB Output is correct
22 Correct 55 ms 1312 KB Output is correct
23 Correct 47 ms 1188 KB Output is correct
24 Correct 49 ms 1132 KB Output is correct
25 Correct 39 ms 1132 KB Output is correct
26 Correct 54 ms 1064 KB Output is correct
27 Correct 48 ms 1132 KB Output is correct
28 Correct 44 ms 1132 KB Output is correct
29 Correct 51 ms 1132 KB Output is correct
30 Correct 36 ms 1132 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# 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 1 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 0 ms 364 KB Output is correct
7 Correct 0 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 1 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 9 ms 492 KB Output is correct
17 Correct 10 ms 492 KB Output is correct
18 Correct 9 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 6 ms 492 KB Output is correct
21 Correct 28 ms 1132 KB Output is correct
22 Correct 29 ms 1176 KB Output is correct
23 Correct 29 ms 1132 KB Output is correct
24 Correct 29 ms 1260 KB Output is correct
25 Correct 59 ms 1296 KB Output is correct
26 Correct 29 ms 1132 KB Output is correct
27 Correct 33 ms 1144 KB Output is correct
28 Correct 29 ms 1132 KB Output is correct
29 Correct 29 ms 1132 KB Output is correct
30 Correct 30 ms 1132 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct