답안 #251441

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251441 2020-07-21T09:23:06 Z atoiz Gap (APIO16_gap) C++14
100 / 100
59 ms 1172 KB
#include "gap.h"
#include <cassert>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iostream>

using namespace std;

long long findGap(int T, int N)
{
	long long L, R;
	long long X = 1e18;
	MinMax(0, X, &L, &R);
	long long maxGap = (R - L + N - 2) / (N - 1);
	if (N == 2) return R - L;
	if (T == 2) {
		while (R - L > maxGap) {
			long long gap = maxGap;
			while (true) {
				long long A, B;
				MinMax(L + 1, L + gap + 1, &A, &B);
				if (A == -1) { gap *= 2; continue; }
				if (maxGap < A - L) maxGap = A - L;
				L = B;
				break;
			}
		}
	} else {
		for (int i = N - 2; i > 0; i -= 2) {
			long long A, B;
			MinMax(L + 1, R - 1, &A, &B);
			if (maxGap < A - L) maxGap = A - L;
			if (maxGap < R - B) maxGap = R - B;
			L = A, R = B;
		}
		if (maxGap < R - L) maxGap = R - L;
	}
	return maxGap;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 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 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 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 13 ms 512 KB Output is correct
17 Correct 12 ms 512 KB Output is correct
18 Correct 12 ms 512 KB Output is correct
19 Correct 14 ms 512 KB Output is correct
20 Correct 8 ms 512 KB Output is correct
21 Correct 54 ms 1172 KB Output is correct
22 Correct 49 ms 1144 KB Output is correct
23 Correct 57 ms 1108 KB Output is correct
24 Correct 51 ms 1144 KB Output is correct
25 Correct 40 ms 1144 KB Output is correct
26 Correct 47 ms 1144 KB Output is correct
27 Correct 50 ms 1144 KB Output is correct
28 Correct 52 ms 1144 KB Output is correct
29 Correct 47 ms 1056 KB Output is correct
30 Correct 34 ms 1052 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 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 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 9 ms 512 KB Output is correct
17 Correct 9 ms 560 KB Output is correct
18 Correct 9 ms 512 KB Output is correct
19 Correct 9 ms 596 KB Output is correct
20 Correct 4 ms 512 KB Output is correct
21 Correct 36 ms 1144 KB Output is correct
22 Correct 34 ms 1144 KB Output is correct
23 Correct 34 ms 1144 KB Output is correct
24 Correct 34 ms 1144 KB Output is correct
25 Correct 59 ms 1164 KB Output is correct
26 Correct 35 ms 1144 KB Output is correct
27 Correct 35 ms 1144 KB Output is correct
28 Correct 36 ms 1144 KB Output is correct
29 Correct 35 ms 1144 KB Output is correct
30 Correct 16 ms 1148 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct