# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
553180 |
2022-04-25T02:21:34 Z |
fcmalkcin |
Gap (APIO16_gap) |
C++17 |
|
63 ms |
2668 KB |
#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-2)/(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;
}*/
# |
Verdict |
Execution time |
Memory |
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 |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
336 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 |
2 ms |
336 KB |
Output is correct |
16 |
Correct |
11 ms |
948 KB |
Output is correct |
17 |
Correct |
11 ms |
976 KB |
Output is correct |
18 |
Correct |
12 ms |
944 KB |
Output is correct |
19 |
Correct |
10 ms |
976 KB |
Output is correct |
20 |
Correct |
9 ms |
976 KB |
Output is correct |
21 |
Correct |
37 ms |
2568 KB |
Output is correct |
22 |
Correct |
38 ms |
2540 KB |
Output is correct |
23 |
Correct |
39 ms |
2624 KB |
Output is correct |
24 |
Correct |
43 ms |
2644 KB |
Output is correct |
25 |
Correct |
32 ms |
2668 KB |
Output is correct |
26 |
Correct |
45 ms |
2628 KB |
Output is correct |
27 |
Correct |
50 ms |
2660 KB |
Output is correct |
28 |
Correct |
47 ms |
2636 KB |
Output is correct |
29 |
Correct |
39 ms |
2596 KB |
Output is correct |
30 |
Correct |
30 ms |
2588 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
0 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 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 |
1 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 |
376 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 |
14 ms |
524 KB |
Output is correct |
17 |
Correct |
15 ms |
464 KB |
Output is correct |
18 |
Correct |
13 ms |
524 KB |
Output is correct |
19 |
Correct |
13 ms |
464 KB |
Output is correct |
20 |
Correct |
9 ms |
464 KB |
Output is correct |
21 |
Correct |
52 ms |
1032 KB |
Output is correct |
22 |
Correct |
56 ms |
1056 KB |
Output is correct |
23 |
Correct |
58 ms |
1036 KB |
Output is correct |
24 |
Correct |
53 ms |
1096 KB |
Output is correct |
25 |
Correct |
53 ms |
1100 KB |
Output is correct |
26 |
Correct |
63 ms |
1068 KB |
Output is correct |
27 |
Correct |
56 ms |
1000 KB |
Output is correct |
28 |
Correct |
50 ms |
1176 KB |
Output is correct |
29 |
Correct |
54 ms |
1096 KB |
Output is correct |
30 |
Correct |
37 ms |
1088 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |