#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const ll MAX=1000000000000000000;
const int maxn=1e5+10;
ll a[maxn];
long long findGap(int T, int N)
{
if (T==1) {
int cur=0;
ll l=0,r=MAX;
rep(i,0,(N+1)/2) {
ll tmp1,tmp2;
MinMax(l,r,&tmp1,&tmp2);
a[cur++]=tmp1,a[N-cur]=tmp2;
l=tmp1+1,r=tmp2-1;
}
ll ans=0;
rep(i,1,N) ans=max(ans,a[i]-a[i-1]);
return ans;
}
ll L,R;
MinMax(0ll,MAX,&L,&R);
debug(L),debug(R);
ll mn=(R-L+N-2)/(N-1);
ll ans=mn;
ll lst=L;
for (ll i=L+1;i<R;i+=mn) {
ll tmp1,tmp2;
MinMax(i,min(i+mn-1,R),&tmp1,&tmp2);
debug(tmp1);debug(lst);
if (tmp1!=-1) {
ans=max(ans,tmp1-lst);
lst=tmp2;
}
}
return max(R-lst,ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
11 ms |
584 KB |
Output is correct |
17 |
Correct |
11 ms |
712 KB |
Output is correct |
18 |
Correct |
11 ms |
584 KB |
Output is correct |
19 |
Correct |
11 ms |
584 KB |
Output is correct |
20 |
Correct |
9 ms |
712 KB |
Output is correct |
21 |
Correct |
43 ms |
1952 KB |
Output is correct |
22 |
Correct |
41 ms |
1856 KB |
Output is correct |
23 |
Correct |
50 ms |
1808 KB |
Output is correct |
24 |
Correct |
46 ms |
1948 KB |
Output is correct |
25 |
Correct |
37 ms |
1876 KB |
Output is correct |
26 |
Correct |
41 ms |
1856 KB |
Output is correct |
27 |
Correct |
41 ms |
1824 KB |
Output is correct |
28 |
Correct |
42 ms |
1824 KB |
Output is correct |
29 |
Correct |
43 ms |
1852 KB |
Output is correct |
30 |
Correct |
36 ms |
1744 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
2 ms |
200 KB |
Output is correct |
8 |
Correct |
2 ms |
200 KB |
Output is correct |
9 |
Correct |
2 ms |
200 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
20 ms |
368 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
21 ms |
328 KB |
Output is correct |
14 |
Correct |
20 ms |
328 KB |
Output is correct |
15 |
Correct |
20 ms |
328 KB |
Output is correct |
16 |
Correct |
322 ms |
1428 KB |
Output is correct |
17 |
Correct |
322 ms |
1512 KB |
Output is correct |
18 |
Correct |
329 ms |
1468 KB |
Output is correct |
19 |
Correct |
324 ms |
1572 KB |
Output is correct |
20 |
Correct |
317 ms |
904 KB |
Output is correct |
21 |
Correct |
1294 ms |
5312 KB |
Output is correct |
22 |
Correct |
1280 ms |
5232 KB |
Output is correct |
23 |
Correct |
1293 ms |
5408 KB |
Output is correct |
24 |
Correct |
1310 ms |
5448 KB |
Output is correct |
25 |
Correct |
1295 ms |
4456 KB |
Output is correct |
26 |
Correct |
1294 ms |
5244 KB |
Output is correct |
27 |
Correct |
1297 ms |
5272 KB |
Output is correct |
28 |
Correct |
1311 ms |
5340 KB |
Output is correct |
29 |
Correct |
1292 ms |
5192 KB |
Output is correct |
30 |
Correct |
1222 ms |
3112 KB |
Output is correct |
31 |
Correct |
2 ms |
328 KB |
Output is correct |
32 |
Correct |
2 ms |
200 KB |
Output is correct |