Submission #372605

# Submission time Handle Problem Language Result Execution time Memory
372605 2021-03-01T05:25:38 Z Bill_00 Gap (APIO16_gap) C++14
100 / 100
55 ms 2060 KB
#include "gap.h"
#include <bits/stdc++.h>
#define N 100005
typedef long long ll;
using namespace std;
ll a[N],mn,mx;
long long findGap(int T, int n)
{
	ll m1=0,m2=1e18,ans=0;
	if(T==1 || n<=10){
		for(int i=1;i<=(n+1)/2;i++){
			MinMax(m1,m2,&mn,&mx);
			a[i]=mn;
			a[n+1-i]=mx;
			m1=mn+1;
			m2=mx-1;
		}
		for(int i=1;i<n;i++){
			ans=max(ans,a[i+1]-a[i]);
		}
		return ans;
	}
	else{
		MinMax(m1,m2,&mn,&mx);
		ll ans=ceil((mx-mn+1)/n);
		ll l=mn,r=mx;
		while(l!=r){
			MinMax(l+1,l+ans,&mn,&mx);
			if(mx!=-1) l=mx;
			else{
				ll y=ans;
				while(mn==-1){
					y*=2;
					MinMax(l+1,l+y,&mn,&mx);
				}
				ans=max(ans,mn-l);
				l=mx;
			}
		}
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 11 ms 748 KB Output is correct
17 Correct 11 ms 748 KB Output is correct
18 Correct 12 ms 824 KB Output is correct
19 Correct 12 ms 748 KB Output is correct
20 Correct 9 ms 748 KB Output is correct
21 Correct 43 ms 1900 KB Output is correct
22 Correct 43 ms 1900 KB Output is correct
23 Correct 42 ms 2060 KB Output is correct
24 Correct 45 ms 2028 KB Output is correct
25 Correct 38 ms 1900 KB Output is correct
26 Correct 43 ms 1900 KB Output is correct
27 Correct 44 ms 2028 KB Output is correct
28 Correct 43 ms 1832 KB Output is correct
29 Correct 42 ms 1900 KB Output is correct
30 Correct 35 ms 1900 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 8 ms 492 KB Output is correct
17 Correct 7 ms 492 KB Output is correct
18 Correct 9 ms 492 KB Output is correct
19 Correct 8 ms 492 KB Output is correct
20 Correct 4 ms 492 KB Output is correct
21 Correct 27 ms 1260 KB Output is correct
22 Correct 28 ms 1260 KB Output is correct
23 Correct 28 ms 1220 KB Output is correct
24 Correct 30 ms 1152 KB Output is correct
25 Correct 55 ms 1132 KB Output is correct
26 Correct 28 ms 1388 KB Output is correct
27 Correct 28 ms 1132 KB Output is correct
28 Correct 28 ms 1132 KB Output is correct
29 Correct 28 ms 1132 KB Output is correct
30 Correct 16 ms 1132 KB Output is correct
31 Correct 0 ms 364 KB Output is correct
32 Correct 0 ms 364 KB Output is correct