Submission #338887

# Submission time Handle Problem Language Result Execution time Memory
338887 2020-12-24T06:27:36 Z Kerim Gap (APIO16_gap) C++17
100 / 100
74 ms 3296 KB
#include "gap.h"
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

typedef long long ll;
const ll B=1e18;
long long findGap(int T, int N){
	ll res=-1;vector<ll>ans;
	if(T==1){ans.resize(N);
		MinMax(0LL,B,&ans[0],&ans[N-1]);
		for(int l=1,r=N-2;l<=r;l++,r--)
			MinMax(ans[l-1]+1,ans[r+1]-1,&ans[l],&ans[r]);	
		for(int i=0;i<N-1;i++)umax(res,ans[i+1]-ans[i]);
		return res;
	}
	ll a,b,mn,mx;
	MinMax(0LL,B,&mn,&mx);
	ll d=(mx-mn-1)/(N-1);ans.pb(mn);
	for(ll l=mn+1;l<mx;l+=d+1){
		MinMax(l,min(l+d,mx-1),&a,&b);
		if(~a)ans.pb(a),ans.pb(b);}
	for(int i=0;i<int(ans.size())-1;i++)umax(res,ans[i+1]-ans[i]);
	return max(res,mx-ans.back());
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 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 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 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 14 ms 748 KB Output is correct
17 Correct 12 ms 708 KB Output is correct
18 Correct 13 ms 748 KB Output is correct
19 Correct 12 ms 748 KB Output is correct
20 Correct 9 ms 748 KB Output is correct
21 Correct 54 ms 2048 KB Output is correct
22 Correct 51 ms 1920 KB Output is correct
23 Correct 47 ms 1900 KB Output is correct
24 Correct 54 ms 1900 KB Output is correct
25 Correct 45 ms 1900 KB Output is correct
26 Correct 47 ms 1900 KB Output is correct
27 Correct 46 ms 2028 KB Output is correct
28 Correct 45 ms 2016 KB Output is correct
29 Correct 45 ms 1900 KB Output is correct
30 Correct 36 ms 1900 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 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 1 ms 364 KB Output is correct
8 Correct 1 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 2 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 396 KB Output is correct
16 Correct 16 ms 912 KB Output is correct
17 Correct 17 ms 1176 KB Output is correct
18 Correct 15 ms 876 KB Output is correct
19 Correct 15 ms 876 KB Output is correct
20 Correct 8 ms 492 KB Output is correct
21 Correct 69 ms 2276 KB Output is correct
22 Correct 63 ms 2276 KB Output is correct
23 Correct 62 ms 2276 KB Output is correct
24 Correct 65 ms 2296 KB Output is correct
25 Correct 61 ms 3296 KB Output is correct
26 Correct 64 ms 2288 KB Output is correct
27 Correct 62 ms 2228 KB Output is correct
28 Correct 74 ms 2408 KB Output is correct
29 Correct 63 ms 2356 KB Output is correct
30 Correct 36 ms 1496 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct