Submission #206214

# Submission time Handle Problem Language Result Execution time Memory
206214 2020-03-02T17:20:03 Z mraron Gap (APIO16_gap) C++14
100 / 100
113 ms 9416 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<ll> res;
int n;

void solve1(ll L, ll R) {
	if((int)res.size()==n||L>R) return ;
	ll a,b;
	MinMax(L,R,&a,&b);
	if(a==-1) return ;
	res.insert(a);
	res.insert(b);
	solve1(a+1,b-1);
}	

void add(ll L, ll R) {
	if((int)res.size()==n||L>R) return ;
	ll a,b;
	MinMax(L,R,&a,&b);
	if(a==-1) return ;
	res.insert(a);
	res.insert(b);
}	

ll findGap(int T, int N)
{
	n=N;
	if(T==2) {
		ll mn,mx;
		MinMax(0, 1000000000000000000LL,&mn,&mx);
		ll val=(mx-mn+n-2)/(n-1);
		res.insert(mn);
		res.insert(mx);
		//cerr<<val<<"\n";
		for(int i=0;i<n-1;++i) {
			add(mn+i*val+1, mn+(i+1)*val);
		}
	}else {
		solve1(0, 1000000000000000000LL);
	}
	vector<ll> ans;
	for(auto i:res) ans.push_back(i);
	ll val=0;
	for(int i=1;i<(int)ans.size();++i) val=max(val, ans[i]-ans[i-1]);
	return val;
	
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 248 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 6 ms 408 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 23 ms 2680 KB Output is correct
17 Correct 23 ms 2680 KB Output is correct
18 Correct 23 ms 2680 KB Output is correct
19 Correct 24 ms 2680 KB Output is correct
20 Correct 18 ms 2680 KB Output is correct
21 Correct 89 ms 9332 KB Output is correct
22 Correct 93 ms 9272 KB Output is correct
23 Correct 83 ms 9328 KB Output is correct
24 Correct 81 ms 9416 KB Output is correct
25 Correct 76 ms 9332 KB Output is correct
26 Correct 82 ms 9316 KB Output is correct
27 Correct 84 ms 9268 KB Output is correct
28 Correct 81 ms 9252 KB Output is correct
29 Correct 84 ms 9332 KB Output is correct
30 Correct 67 ms 9204 KB Output is correct
31 Correct 4 ms 248 KB Output is correct
32 Correct 5 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 252 KB Output is correct
2 Correct 4 ms 248 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 5 ms 248 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 4 ms 248 KB Output is correct
10 Correct 5 ms 248 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 6 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 26 ms 1896 KB Output is correct
17 Correct 26 ms 1912 KB Output is correct
18 Correct 28 ms 1912 KB Output is correct
19 Correct 25 ms 1912 KB Output is correct
20 Correct 12 ms 504 KB Output is correct
21 Correct 98 ms 6388 KB Output is correct
22 Correct 99 ms 6388 KB Output is correct
23 Correct 107 ms 6388 KB Output is correct
24 Correct 100 ms 6512 KB Output is correct
25 Correct 102 ms 6896 KB Output is correct
26 Correct 113 ms 6512 KB Output is correct
27 Correct 108 ms 6516 KB Output is correct
28 Correct 98 ms 6520 KB Output is correct
29 Correct 108 ms 6384 KB Output is correct
30 Correct 51 ms 2424 KB Output is correct
31 Correct 4 ms 248 KB Output is correct
32 Correct 4 ms 248 KB Output is correct