답안 #111374

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111374 2019-05-15T03:14:57 Z diamond_duke Gap (APIO16_gap) C++11
100 / 100
86 ms 2040 KB
#include <algorithm>
#include <cstdio>
#include "gap.h"
using ll = long long;
ll arr[100005];
inline ll calc(int n)
{
	ll res = 0;
	for (int i = 1; i < n; i++)
		res = std::max(res, arr[i] - arr[i - 1]);
	return res;
}
ll findGap(int sub, int n)
{
	if (sub == 1)
	{
		for (int l = 0, r = n - 1; l <= r; l++, r--)
		{
			ll pre = l ? arr[l - 1] + 1 : 0;
			ll nxt = r + 1 < n ? arr[r + 1] - 1 : (ll)1e18;
			MinMax(pre, nxt, arr + l, arr + r);
		}
		return calc(n);
	}
	ll mn, mx, cnt = 0;
	MinMax(0, 1e18, &mn, &mx);
	ll blk = (mx - mn) / (n - 1);
	for (ll i = mn; i <= mx; i += blk + 1)
	{
		ll x, y;
		MinMax(i, i + blk, &x, &y);
		if (~x)
			arr[cnt++] = x;
		if (x != y)
			arr[cnt++] = y;
	}
	return std::max(blk, calc(cnt));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 13 ms 640 KB Output is correct
17 Correct 12 ms 768 KB Output is correct
18 Correct 14 ms 768 KB Output is correct
19 Correct 13 ms 768 KB Output is correct
20 Correct 10 ms 768 KB Output is correct
21 Correct 53 ms 1912 KB Output is correct
22 Correct 62 ms 1912 KB Output is correct
23 Correct 49 ms 1916 KB Output is correct
24 Correct 48 ms 1912 KB Output is correct
25 Correct 56 ms 1912 KB Output is correct
26 Correct 52 ms 1912 KB Output is correct
27 Correct 52 ms 1912 KB Output is correct
28 Correct 68 ms 1876 KB Output is correct
29 Correct 53 ms 1912 KB Output is correct
30 Correct 40 ms 1928 KB Output is correct
31 Correct 0 ms 256 KB Output is correct
32 Correct 3 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 18 ms 640 KB Output is correct
17 Correct 20 ms 668 KB Output is correct
18 Correct 24 ms 744 KB Output is correct
19 Correct 17 ms 768 KB Output is correct
20 Correct 8 ms 512 KB Output is correct
21 Correct 62 ms 1784 KB Output is correct
22 Correct 73 ms 1800 KB Output is correct
23 Correct 78 ms 1784 KB Output is correct
24 Correct 83 ms 1784 KB Output is correct
25 Correct 71 ms 2040 KB Output is correct
26 Correct 84 ms 1744 KB Output is correct
27 Correct 86 ms 1784 KB Output is correct
28 Correct 72 ms 1784 KB Output is correct
29 Correct 76 ms 1916 KB Output is correct
30 Correct 40 ms 1272 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct