Submission #409733

# Submission time Handle Problem Language Result Execution time Memory
409733 2021-05-21T12:21:48 Z naranbat Gap (APIO16_gap) C++17
100 / 100
60 ms 1844 KB
#include "gap.h"
#include<bits/stdc++.h>
const long long INF = 1e18 + 6;
using namespace std;

long long a[100005];

long long findGap(int T, int N)
{
	if(T == 1){
		int l = 0;
		int r = N - 1;
		long long mn = 0, mx = INF;
		long long h,h1;
		while(l <= r){
			MinMax(mn, mx, &h, &h1);
			a[l] = h;
			a[r] = h1;
			l++;
			r--;
			mn = h + 1;
			mx = h1 - 1;
		}
		long long ans = 0;
		for(int i = 1; i < N; i++){
			ans = max(ans,a[i] - a[i - 1]);
		}
		return ans;
	}
	else{
		long long mn,mx;
		MinMax(0, INF, &mn, &mx);
		a[0] = mn;
		a[N] = mx;
		long long x = (mx - mn + N - 2) / (N - 1) + 1;

		long long ans = x - 1;
		long long l = mn + 1, last = mn;

		while(last + x < a[N]){
			MinMax(l, l + x - 1, &mn, &mx);
			if(mn == -1){
				l += x;
			} else{
				ans = max(ans, mn - last);
				last = mx;
				l = last + 1;
			}
			x = max(ans, x + 1);
		}
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 12 ms 704 KB Output is correct
17 Correct 12 ms 700 KB Output is correct
18 Correct 12 ms 584 KB Output is correct
19 Correct 12 ms 584 KB Output is correct
20 Correct 11 ms 672 KB Output is correct
21 Correct 50 ms 1816 KB Output is correct
22 Correct 45 ms 1816 KB Output is correct
23 Correct 45 ms 1776 KB Output is correct
24 Correct 47 ms 1844 KB Output is correct
25 Correct 43 ms 1808 KB Output is correct
26 Correct 45 ms 1752 KB Output is correct
27 Correct 47 ms 1776 KB Output is correct
28 Correct 44 ms 1764 KB Output is correct
29 Correct 45 ms 1824 KB Output is correct
30 Correct 43 ms 1820 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 228 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 9 ms 456 KB Output is correct
17 Correct 9 ms 456 KB Output is correct
18 Correct 9 ms 460 KB Output is correct
19 Correct 9 ms 456 KB Output is correct
20 Correct 4 ms 404 KB Output is correct
21 Correct 29 ms 988 KB Output is correct
22 Correct 35 ms 1056 KB Output is correct
23 Correct 29 ms 960 KB Output is correct
24 Correct 31 ms 1008 KB Output is correct
25 Correct 60 ms 1036 KB Output is correct
26 Correct 31 ms 1056 KB Output is correct
27 Correct 30 ms 1008 KB Output is correct
28 Correct 31 ms 1080 KB Output is correct
29 Correct 30 ms 1084 KB Output is correct
30 Correct 15 ms 1008 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct