# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
489217 |
2021-11-21T15:22:39 Z |
leaked |
Gap (APIO16_gap) |
C++14 |
|
50 ms |
7324 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define f first
#define s second
pair<ll,ll> ask(ll l,ll r){
if(l>r) return {-1,-1};
ll *a,*b;
a=new long long(),b=new long long();
MinMax(l,r,a,b);
return {*a,*b};
}
long long findGap(int T, int N)
{
if(T==1){
long long x=0,y=1e18;
vector<long long>vc;
while(N>=1){
long long *a,*b;
a=new long long(),b=new long long();
MinMax(x,y,a,b);
x=*a,y=*b;
vc.push_back(x);
vc.push_back(y);
x++;y--;
N-=2;
}
sort(vc.begin(),vc.end());
long long ans=0;
for(int i=1;i<(int)vc.size();i++)
ans=max(ans,vc[i]-vc[i-1]);
return ans;
}
else{
long long x=0;
ll y=1e18;
auto c=ask(x,y);
x=c.f,y=c.s;
ll d=ceil((ld)(y-x)/(N-1));
ll ans=d;
// d++;
while(x+ans<y){
ll cnt=1;
while(1){
c=ask(x+1,min(y-1,x+cnt*ans));
if(c.f==-1 && x+cnt*ans>=y){
ans=max(ans,y-x);
return ans;
}
if(c.f!=-1)
break;
else
cnt++;
}
ans=max(ans,c.f-x);
x=c.s;
}
ans=max(ans,y-x);
return ans;
}
return 0;
}
/*
n+
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 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 |
10 ms |
1476 KB |
Output is correct |
17 |
Correct |
11 ms |
1484 KB |
Output is correct |
18 |
Correct |
11 ms |
1476 KB |
Output is correct |
19 |
Correct |
10 ms |
1476 KB |
Output is correct |
20 |
Correct |
8 ms |
1476 KB |
Output is correct |
21 |
Correct |
41 ms |
5004 KB |
Output is correct |
22 |
Correct |
48 ms |
4952 KB |
Output is correct |
23 |
Correct |
46 ms |
4996 KB |
Output is correct |
24 |
Correct |
42 ms |
5004 KB |
Output is correct |
25 |
Correct |
39 ms |
4948 KB |
Output is correct |
26 |
Correct |
42 ms |
4928 KB |
Output is correct |
27 |
Correct |
41 ms |
5000 KB |
Output is correct |
28 |
Correct |
43 ms |
4916 KB |
Output is correct |
29 |
Correct |
42 ms |
5012 KB |
Output is correct |
30 |
Correct |
36 ms |
4940 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 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 |
7 ms |
676 KB |
Output is correct |
17 |
Correct |
6 ms |
584 KB |
Output is correct |
18 |
Correct |
6 ms |
628 KB |
Output is correct |
19 |
Correct |
7 ms |
672 KB |
Output is correct |
20 |
Correct |
5 ms |
1224 KB |
Output is correct |
21 |
Correct |
22 ms |
1612 KB |
Output is correct |
22 |
Correct |
25 ms |
1648 KB |
Output is correct |
23 |
Correct |
25 ms |
1656 KB |
Output is correct |
24 |
Correct |
23 ms |
1600 KB |
Output is correct |
25 |
Correct |
50 ms |
7324 KB |
Output is correct |
26 |
Correct |
29 ms |
1712 KB |
Output is correct |
27 |
Correct |
23 ms |
1692 KB |
Output is correct |
28 |
Correct |
27 ms |
1856 KB |
Output is correct |
29 |
Correct |
24 ms |
1612 KB |
Output is correct |
30 |
Correct |
21 ms |
3956 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |