답안 #261464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261464 2020-08-11T18:24:46 Z srvlt Gap (APIO16_gap) C++14
100 / 100
72 ms 1272 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include "gap.h"

ll findGap(int T, int N) {
	if (T == 1) {
		ll l = -1, r = 2e18, mn, mx;
		ll ans = 0;
		int cnt = 0;
		while (cnt < N) {
			if (l + 1 > r - 1) break;
			MinMax(l + 1, r - 1, & mn, & mx);
			if (mn == -1) break;
			if (l >= 0) {
				ans = max(ans, mn - l);
				ans = max(ans, r - mx);
			}
			l = mn, r = mx;
			cnt += 2;
		}
		ans = max(ans, r - l);
		return ans;
	}
	ll mn = 0, mx = 0;
	MinMax(0ll, 1e18, & mn, & mx);
	ll step = (mx - mn) / (N - 1);
	ll ans = step, L = 0, R = mn - 1, last = -1;
	
	ll l, r;
	for (int i = 1; i < N; i++) {
		L = R + 1;
		R = L + step;
		MinMax(L, R, & l, & r);
		if (i > 1 && l != -1 && last != -1)
			ans = max(ans, l - last);
		if (l != -1)
			last = r;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 15 ms 512 KB Output is correct
17 Correct 16 ms 512 KB Output is correct
18 Correct 14 ms 512 KB Output is correct
19 Correct 14 ms 512 KB Output is correct
20 Correct 10 ms 512 KB Output is correct
21 Correct 49 ms 1144 KB Output is correct
22 Correct 48 ms 1144 KB Output is correct
23 Correct 48 ms 1144 KB Output is correct
24 Correct 50 ms 1096 KB Output is correct
25 Correct 41 ms 1172 KB Output is correct
26 Correct 48 ms 1144 KB Output is correct
27 Correct 49 ms 1136 KB Output is correct
28 Correct 48 ms 1144 KB Output is correct
29 Correct 48 ms 1152 KB Output is correct
30 Correct 34 ms 1172 KB Output is correct
31 Correct 1 ms 288 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 356 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 16 ms 512 KB Output is correct
17 Correct 16 ms 512 KB Output is correct
18 Correct 16 ms 512 KB Output is correct
19 Correct 16 ms 512 KB Output is correct
20 Correct 7 ms 512 KB Output is correct
21 Correct 66 ms 1084 KB Output is correct
22 Correct 68 ms 1144 KB Output is correct
23 Correct 64 ms 1144 KB Output is correct
24 Correct 64 ms 1068 KB Output is correct
25 Correct 59 ms 1152 KB Output is correct
26 Correct 72 ms 1148 KB Output is correct
27 Correct 64 ms 1096 KB Output is correct
28 Correct 72 ms 1272 KB Output is correct
29 Correct 65 ms 1068 KB Output is correct
30 Correct 35 ms 1152 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct