#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
//#define endl "\n"
#define pb push_back
#define F(i,a,b) for(ll i=a;i<=b;i++)
const ll maxn=1e3+5e2+100;
const ll base=3e18;
const ll mod= 1e9+7 ;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
ll findGap(int t,int n)
{
if (t==1)
{
ll l=-1,h=1e18;
h++;
// cout <<h<<endl;
vector<ll> vt;
vector<ll> vt1;
ll mn,mx;
ll res=0;
// cout <<l<<" "<<h<<endl;
for (int i=1; i<=(n+1)/2; i++)
{
MinMax(l+1,h-1,&mn,&mx);
vt.pb(mn);
vt1.pb(mx);
l=mn;
h=mx;
}
reverse(vt1.begin(),vt1.end());
for (auto to:vt1)
vt.pb(to);
for (int i=1; i<(ll)vt.size(); i++)
res=max(res,vt[i]-vt[i-1]);
return res;
}
else
{
ll mn,mx;
MinMax(0,1e18,&mn,&mx);
ll len=mx-mn;
ll pt=mx;
ll h=(len+n-1)/(n-1);
h--;
ll l=mn+1;
ll pre=mn;
ll res=0;
while (l<=pt)
{
MinMax(l,l+h,&mn,&mx);
l+=(h+1);
if (mn!=-1)
{
res=max(res,mn-pre);
pre=mx;
}
else
{
}
}
return res;
}
}
/*int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("t.inp","r"))
{
freopen("test.inp","r",stdin);
freopen("test.out","w",stdout);
}
cout <<findGap(1,10)<<endl;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
1 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 |
10 ms |
976 KB |
Output is correct |
17 |
Correct |
10 ms |
996 KB |
Output is correct |
18 |
Correct |
16 ms |
976 KB |
Output is correct |
19 |
Correct |
13 ms |
944 KB |
Output is correct |
20 |
Correct |
8 ms |
976 KB |
Output is correct |
21 |
Correct |
35 ms |
2544 KB |
Output is correct |
22 |
Correct |
36 ms |
2584 KB |
Output is correct |
23 |
Correct |
40 ms |
2640 KB |
Output is correct |
24 |
Correct |
41 ms |
2644 KB |
Output is correct |
25 |
Correct |
38 ms |
2624 KB |
Output is correct |
26 |
Correct |
37 ms |
2540 KB |
Output is correct |
27 |
Correct |
40 ms |
2636 KB |
Output is correct |
28 |
Correct |
51 ms |
2636 KB |
Output is correct |
29 |
Correct |
42 ms |
2600 KB |
Output is correct |
30 |
Correct |
28 ms |
2620 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 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 |
1 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 |
12 ms |
436 KB |
Output is correct |
17 |
Correct |
12 ms |
520 KB |
Output is correct |
18 |
Correct |
14 ms |
528 KB |
Output is correct |
19 |
Correct |
13 ms |
464 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
49 ms |
968 KB |
Output is correct |
22 |
Correct |
56 ms |
1084 KB |
Output is correct |
23 |
Correct |
63 ms |
1092 KB |
Output is correct |
24 |
Correct |
55 ms |
1064 KB |
Output is correct |
25 |
Correct |
47 ms |
1080 KB |
Output is correct |
26 |
Correct |
53 ms |
1088 KB |
Output is correct |
27 |
Correct |
54 ms |
1160 KB |
Output is correct |
28 |
Correct |
64 ms |
1220 KB |
Output is correct |
29 |
Correct |
49 ms |
1104 KB |
Output is correct |
30 |
Correct |
27 ms |
1108 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |