답안 #32039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
32039 2017-09-23T10:13:41 Z imeimi2000 Gap (APIO16_gap) C++14
100 / 100
83 ms 4236 KB
#include "gap.h"
#include <algorithm>

using namespace std;
typedef long long llong;

int n;
const llong m = 1e18;
llong divpro(llong s, llong t) {
	llong ret = 0;
	llong a, b;
	llong q = (t - s - 1) / n;
	llong r = (t - s - 1) - q * n;
	llong pree = s;
	for (llong i = 0, j = s; i < n; ++i) {
		llong dis = q + (i < r);
		MinMax(j + 1, j + dis, &a, &b);
		j += dis;
		if (a == -1) continue;
		ret = max(ret, a - pree);
		pree = b;
 	}
	return max(ret, t - pree);
}

long long findGap(int T, int N)
{
	n = N;
	llong s, t;
	MinMax(0, m, &s, &t);
	if (n == 2) return t - s;
	n -= 2;
	if (T == 1) {
		llong ret = 0;
		llong i = s, j = t;
		while (n > 0) {
			MinMax(i + 1, j - 1, &i, &j);
			n -= 2;
			ret = max(ret, max(t - j, i - s));
			s = i; t = j;
		}
		return ret;
	}
	else {
		return divpro(s, t);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4236 KB Output is correct
2 Correct 0 ms 4236 KB Output is correct
3 Correct 0 ms 4236 KB Output is correct
4 Correct 0 ms 4236 KB Output is correct
5 Correct 0 ms 4236 KB Output is correct
6 Correct 0 ms 4236 KB Output is correct
7 Correct 0 ms 4236 KB Output is correct
8 Correct 0 ms 4236 KB Output is correct
9 Correct 0 ms 4236 KB Output is correct
10 Correct 0 ms 4236 KB Output is correct
11 Correct 0 ms 4236 KB Output is correct
12 Correct 0 ms 4236 KB Output is correct
13 Correct 0 ms 4236 KB Output is correct
14 Correct 0 ms 4236 KB Output is correct
15 Correct 0 ms 4236 KB Output is correct
16 Correct 13 ms 4236 KB Output is correct
17 Correct 13 ms 4236 KB Output is correct
18 Correct 16 ms 4236 KB Output is correct
19 Correct 6 ms 4236 KB Output is correct
20 Correct 13 ms 4236 KB Output is correct
21 Correct 59 ms 4236 KB Output is correct
22 Correct 76 ms 4236 KB Output is correct
23 Correct 73 ms 4236 KB Output is correct
24 Correct 53 ms 4236 KB Output is correct
25 Correct 43 ms 4236 KB Output is correct
26 Correct 36 ms 4236 KB Output is correct
27 Correct 56 ms 4236 KB Output is correct
28 Correct 53 ms 4236 KB Output is correct
29 Correct 69 ms 4236 KB Output is correct
30 Correct 36 ms 4236 KB Output is correct
31 Correct 0 ms 4236 KB Output is correct
32 Correct 0 ms 4236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4236 KB Output is correct
2 Correct 0 ms 4236 KB Output is correct
3 Correct 0 ms 4236 KB Output is correct
4 Correct 0 ms 4236 KB Output is correct
5 Correct 0 ms 4236 KB Output is correct
6 Correct 0 ms 4236 KB Output is correct
7 Correct 0 ms 4236 KB Output is correct
8 Correct 0 ms 4236 KB Output is correct
9 Correct 0 ms 4236 KB Output is correct
10 Correct 0 ms 4236 KB Output is correct
11 Correct 0 ms 4236 KB Output is correct
12 Correct 0 ms 4236 KB Output is correct
13 Correct 0 ms 4236 KB Output is correct
14 Correct 0 ms 4236 KB Output is correct
15 Correct 0 ms 4236 KB Output is correct
16 Correct 26 ms 4236 KB Output is correct
17 Correct 13 ms 4236 KB Output is correct
18 Correct 16 ms 4236 KB Output is correct
19 Correct 16 ms 4236 KB Output is correct
20 Correct 6 ms 4236 KB Output is correct
21 Correct 69 ms 4236 KB Output is correct
22 Correct 73 ms 4236 KB Output is correct
23 Correct 66 ms 4236 KB Output is correct
24 Correct 69 ms 4236 KB Output is correct
25 Correct 69 ms 4236 KB Output is correct
26 Correct 79 ms 4236 KB Output is correct
27 Correct 83 ms 4236 KB Output is correct
28 Correct 73 ms 4236 KB Output is correct
29 Correct 76 ms 4236 KB Output is correct
30 Correct 39 ms 4236 KB Output is correct
31 Correct 0 ms 4236 KB Output is correct
32 Correct 0 ms 4236 KB Output is correct