Submission #40875

# Submission time Handle Problem Language Result Execution time Memory
40875 2018-02-09T15:56:44 Z gabrielsimoes Gap (APIO16_gap) C++14
100 / 100
88 ms 2284 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000000000;

ll findGap(int T, int N) {
	if (T == 1) {
		ll v[N], mn = -1, mx = INF+1;
		for (int i = 0, k = N-1; i <= k; i++, k--) {
			MinMax(mn+1, mx-1, &v[i], &v[k]);
			mn = v[i];
			mx = v[k];
		}

		ll ans = 0;
		for (int i = 1; i < N; i++) {
			ans = max(ans, v[i] - v[i-1]);
		}

		return ans;
	} else {
		ll total_min, total_max;
		MinMax(0, INF, &total_min, &total_max);

		ll ans = (total_max - total_min + ll(N - 1))/ll(N);
		ll cur = total_min;
		while(cur < total_max) {
			ll mn = -1, mx = -1;
			ll step = ans;
			while (mn == -1) {
				MinMax(cur+1, cur+step+1, &mn, &mx);
				step += ans;
			}

			ans = max(ans, mn - cur);
			cur = mx;
		}

		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 428 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 1 ms 552 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 1 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 3 ms 720 KB Output is correct
16 Correct 14 ms 1004 KB Output is correct
17 Correct 15 ms 1004 KB Output is correct
18 Correct 19 ms 1004 KB Output is correct
19 Correct 17 ms 1004 KB Output is correct
20 Correct 10 ms 1004 KB Output is correct
21 Correct 52 ms 2088 KB Output is correct
22 Correct 73 ms 2136 KB Output is correct
23 Correct 52 ms 2284 KB Output is correct
24 Correct 63 ms 2284 KB Output is correct
25 Correct 45 ms 2284 KB Output is correct
26 Correct 52 ms 2284 KB Output is correct
27 Correct 60 ms 2284 KB Output is correct
28 Correct 54 ms 2284 KB Output is correct
29 Correct 53 ms 2284 KB Output is correct
30 Correct 38 ms 2284 KB Output is correct
31 Correct 2 ms 2284 KB Output is correct
32 Correct 1 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2284 KB Output is correct
2 Correct 1 ms 2284 KB Output is correct
3 Correct 1 ms 2284 KB Output is correct
4 Correct 1 ms 2284 KB Output is correct
5 Correct 1 ms 2284 KB Output is correct
6 Correct 1 ms 2284 KB Output is correct
7 Correct 1 ms 2284 KB Output is correct
8 Correct 1 ms 2284 KB Output is correct
9 Correct 2 ms 2284 KB Output is correct
10 Correct 1 ms 2284 KB Output is correct
11 Correct 2 ms 2284 KB Output is correct
12 Correct 2 ms 2284 KB Output is correct
13 Correct 2 ms 2284 KB Output is correct
14 Correct 2 ms 2284 KB Output is correct
15 Correct 2 ms 2284 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
17 Correct 16 ms 2284 KB Output is correct
18 Correct 10 ms 2284 KB Output is correct
19 Correct 16 ms 2284 KB Output is correct
20 Correct 12 ms 2284 KB Output is correct
21 Correct 52 ms 2284 KB Output is correct
22 Correct 37 ms 2284 KB Output is correct
23 Correct 48 ms 2284 KB Output is correct
24 Correct 40 ms 2284 KB Output is correct
25 Correct 88 ms 2284 KB Output is correct
26 Correct 43 ms 2284 KB Output is correct
27 Correct 35 ms 2284 KB Output is correct
28 Correct 41 ms 2284 KB Output is correct
29 Correct 46 ms 2284 KB Output is correct
30 Correct 25 ms 2284 KB Output is correct
31 Correct 1 ms 2284 KB Output is correct
32 Correct 1 ms 2284 KB Output is correct