#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
512 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
512 KB |
Output is correct |
14 |
Correct |
5 ms |
416 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
24 ms |
2688 KB |
Output is correct |
17 |
Correct |
22 ms |
2688 KB |
Output is correct |
18 |
Correct |
25 ms |
2680 KB |
Output is correct |
19 |
Correct |
22 ms |
2680 KB |
Output is correct |
20 |
Correct |
18 ms |
2688 KB |
Output is correct |
21 |
Correct |
92 ms |
9312 KB |
Output is correct |
22 |
Correct |
83 ms |
9280 KB |
Output is correct |
23 |
Correct |
84 ms |
9332 KB |
Output is correct |
24 |
Correct |
85 ms |
9224 KB |
Output is correct |
25 |
Correct |
83 ms |
9332 KB |
Output is correct |
26 |
Correct |
89 ms |
9332 KB |
Output is correct |
27 |
Correct |
88 ms |
9332 KB |
Output is correct |
28 |
Correct |
90 ms |
9204 KB |
Output is correct |
29 |
Correct |
81 ms |
9332 KB |
Output is correct |
30 |
Correct |
67 ms |
9336 KB |
Output is correct |
31 |
Correct |
5 ms |
256 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
432 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
512 KB |
Output is correct |
12 |
Correct |
7 ms |
512 KB |
Output is correct |
13 |
Correct |
6 ms |
512 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
24 ms |
1964 KB |
Output is correct |
17 |
Correct |
25 ms |
1936 KB |
Output is correct |
18 |
Correct |
27 ms |
1904 KB |
Output is correct |
19 |
Correct |
25 ms |
1920 KB |
Output is correct |
20 |
Correct |
13 ms |
512 KB |
Output is correct |
21 |
Correct |
101 ms |
6388 KB |
Output is correct |
22 |
Correct |
98 ms |
6388 KB |
Output is correct |
23 |
Correct |
106 ms |
6516 KB |
Output is correct |
24 |
Correct |
113 ms |
6536 KB |
Output is correct |
25 |
Correct |
100 ms |
7028 KB |
Output is correct |
26 |
Correct |
113 ms |
6516 KB |
Output is correct |
27 |
Correct |
97 ms |
6388 KB |
Output is correct |
28 |
Correct |
105 ms |
6432 KB |
Output is correct |
29 |
Correct |
97 ms |
6516 KB |
Output is correct |
30 |
Correct |
48 ms |
2296 KB |
Output is correct |
31 |
Correct |
4 ms |
256 KB |
Output is correct |
32 |
Correct |
4 ms |
256 KB |
Output is correct |