답안 #956518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
956518 2024-04-02T06:39:24 Z thinknoexit Gap (APIO16_gap) C++17
100 / 100
40 ms 2400 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
ll a[100100];
int n;
ll ans = 1;
ll findGap(int T, int N) {
	n = N;
	if (T == 1) {
		a[0] = -1, a[n + 1] = inf + 1;
		for (int i = 1;i <= n / 2;i++) {
			MinMax(a[i - 1] + 1, a[n - i + 2] - 1, &a[i], &a[n - i + 1]);
		}
		if (n & 1) {
			ll _;
			MinMax(a[n / 2] + 1, a[n / 2 + 2] - 1, &a[n / 2 + 1], &_);
		}
		for (int i = 1;i < n;i++) {
			ans = max(ans, a[i + 1] - a[i]);
		}
		return ans;
	}
	ll mn, mx;
	MinMax(0, inf, &mn, &mx);
	ans = (mx - mn) / (n - 1);
	ll now = mn;
	while (now < mx) {
		ll n1, n2;
		ll t = ans;
		for (;;t *= 2ll) {
			MinMax(now + 1, now + t, &n1, &n2);
			if (n1 != -1) break;
		}
		ans = max(ans, n1 - now);
		now = n2;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 592 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 8 ms 932 KB Output is correct
17 Correct 7 ms 644 KB Output is correct
18 Correct 8 ms 644 KB Output is correct
19 Correct 8 ms 884 KB Output is correct
20 Correct 7 ms 732 KB Output is correct
21 Correct 30 ms 1984 KB Output is correct
22 Correct 30 ms 1996 KB Output is correct
23 Correct 30 ms 2152 KB Output is correct
24 Correct 34 ms 2228 KB Output is correct
25 Correct 31 ms 1960 KB Output is correct
26 Correct 29 ms 1968 KB Output is correct
27 Correct 30 ms 1984 KB Output is correct
28 Correct 30 ms 1984 KB Output is correct
29 Correct 29 ms 1984 KB Output is correct
30 Correct 29 ms 2400 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 5 ms 680 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 5 ms 708 KB Output is correct
19 Correct 5 ms 648 KB Output is correct
20 Correct 3 ms 620 KB Output is correct
21 Correct 18 ms 1212 KB Output is correct
22 Correct 18 ms 1384 KB Output is correct
23 Correct 20 ms 1112 KB Output is correct
24 Correct 18 ms 1212 KB Output is correct
25 Correct 40 ms 1212 KB Output is correct
26 Correct 19 ms 1212 KB Output is correct
27 Correct 24 ms 1192 KB Output is correct
28 Correct 20 ms 1220 KB Output is correct
29 Correct 18 ms 1208 KB Output is correct
30 Correct 11 ms 1148 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct