#include "gap.h"
// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
ll n;
ll t;
ll findGap(int T, int N)
{
n = N;
t = T;
if(t==1){
ll l = 1,r = 1000000000;
r*=r;
vector<ll> v;
while(l<=r){
ll x,y;
if(sz(v)==n) break;
MinMax(l,r,&x,&y);
if(x==-1&&y==-1) break;
if(x==y){
v.pb(x);
break;
}else{
v.pb(x);
v.pb(y);
r = y-1;
l = x+1;
}
}
sort(all(v));
ll ans = 0;
for(ll i = 0;i<sz(v)-1;i++){
ans = max(ans,v[i+1]-v[i]);
}
return ans;
}
ll l = 1,r = 1000000000;
r*=r;
ll mini,maxi;
MinMax(l,r,&mini,&maxi);
ll d = (maxi-mini)/(n-1);
cerr<<"d: "<<d<<endl;
if(d==0) return 0;
vector<ll> v = {mini,maxi};
if((mini%(n-1)!=maxi%(n-1))) d++;
for(ll i = mini;i<=maxi;i+=d){
ll x,y;
ll l = i+1,r = i+d;
MinMax(l,r,&x,&y);
if(x==-1&&y==-1) continue;
v.pb(x);
v.pb(y);
}
ll ans = 0;
sort(all(v));
for(ll i = 0;i<sz(v)-1;i++) ans = max(ans,v[i+1]-v[i]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
884 KB |
Output is correct |
17 |
Correct |
11 ms |
884 KB |
Output is correct |
18 |
Correct |
11 ms |
848 KB |
Output is correct |
19 |
Correct |
13 ms |
976 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
43 ms |
2188 KB |
Output is correct |
22 |
Correct |
43 ms |
2172 KB |
Output is correct |
23 |
Correct |
43 ms |
2204 KB |
Output is correct |
24 |
Correct |
43 ms |
2176 KB |
Output is correct |
25 |
Correct |
38 ms |
2376 KB |
Output is correct |
26 |
Correct |
41 ms |
2248 KB |
Output is correct |
27 |
Correct |
42 ms |
2236 KB |
Output is correct |
28 |
Correct |
50 ms |
2184 KB |
Output is correct |
29 |
Correct |
42 ms |
2220 KB |
Output is correct |
30 |
Correct |
42 ms |
2280 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
16 ms |
816 KB |
Output is correct |
17 |
Correct |
18 ms |
840 KB |
Output is correct |
18 |
Correct |
15 ms |
836 KB |
Output is correct |
19 |
Correct |
13 ms |
848 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
53 ms |
2184 KB |
Output is correct |
22 |
Correct |
65 ms |
2240 KB |
Output is correct |
23 |
Correct |
62 ms |
2240 KB |
Output is correct |
24 |
Correct |
54 ms |
2252 KB |
Output is correct |
25 |
Correct |
52 ms |
3228 KB |
Output is correct |
26 |
Correct |
73 ms |
2220 KB |
Output is correct |
27 |
Correct |
55 ms |
2208 KB |
Output is correct |
28 |
Correct |
52 ms |
2200 KB |
Output is correct |
29 |
Correct |
55 ms |
2164 KB |
Output is correct |
30 |
Correct |
34 ms |
1440 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |