답안 #110892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110892 2019-05-12T22:34:53 Z luciocf Gap (APIO16_gap) C++14
100 / 100
61 ms 2040 KB
#include <bits/stdc++.h>
#include "gap.h"
 
using namespace std;
 
const int maxn = 1e5+10;
const long long maxv = 1e18+10;
 
typedef long long ll;
 
ll a[maxn];
 
long long findGap(int T, int N)
{
	if (T == 1)
	{
		ll mn, mx;
		MinMax(0, maxv, &mn, &mx);
 
		int l = 1, r = N;
		a[1] = mn, a[N] = mx;
 
		while (true)
		{
			if (r-l <= 1) break;
 
			MinMax(a[l]+1, a[r]-1, &mn, &mx);
 
			a[++l] = mn, a[--r] = mx;
		}
 
		ll ans = 0;
		for (int i = 1; i < N; i++)
			ans = max(ans, a[i+1]-a[i]);
 
		return ans;
	}
 
	ll mn, mx;
	MinMax(0, 1e18, &mn, &mx);
 
	a[1] = mn, a[N] = mx;
	ll delta = (mx-mn)/(N-1);
 
	ll first = a[1], cur = a[1]+1;
	ll ans = 0;
 
	while (true)
	{
		if (cur > a[N])
			return ans;
 
		MinMax(cur, cur+delta-1, &mn, &mx);
 
		if (mn == -1)
		{
			cur += delta;
			continue;
		}
		else
		{
			ans = max(ans, mn-first);
			
			cur += delta;
			first = mx;

			delta = max(delta, ans);
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 4 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 2 ms 384 KB Output is correct
16 Correct 13 ms 768 KB Output is correct
17 Correct 13 ms 768 KB Output is correct
18 Correct 13 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 56 ms 1864 KB Output is correct
22 Correct 46 ms 1912 KB Output is correct
23 Correct 52 ms 1912 KB Output is correct
24 Correct 48 ms 1916 KB Output is correct
25 Correct 61 ms 1936 KB Output is correct
26 Correct 50 ms 1912 KB Output is correct
27 Correct 51 ms 2040 KB Output is correct
28 Correct 49 ms 1912 KB Output is correct
29 Correct 52 ms 1884 KB Output is correct
30 Correct 39 ms 1852 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 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 4 ms 384 KB Output is correct
12 Correct 4 ms 428 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 10 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 7 ms 512 KB Output is correct
21 Correct 37 ms 1152 KB Output is correct
22 Correct 46 ms 1272 KB Output is correct
23 Correct 49 ms 1164 KB Output is correct
24 Correct 51 ms 1144 KB Output is correct
25 Correct 61 ms 1144 KB Output is correct
26 Correct 32 ms 1144 KB Output is correct
27 Correct 33 ms 1232 KB Output is correct
28 Correct 34 ms 1144 KB Output is correct
29 Correct 31 ms 1144 KB Output is correct
30 Correct 29 ms 1152 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct