# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
910457 |
2024-01-18T05:13:06 Z |
ibm2006 |
Gap (APIO16_gap) |
C++17 |
|
44 ms |
3524 KB |
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,s,l,r,x,y,z,w,a[1100000],i,j,k,m,mx,gap;
long long findGap(int T, int N)
{
n=N;
if(T==1)
{
l=0;
r=1e18-1;
x=1;
y=n;
while(l<r)
{
MinMax(l,r,&l,&r);
a[x]=l;
a[y]=r;
x++;
y--;
if(l==r||x>y)
break;
l++;
r--;
}
for(i=1;i<n;i++)
{
s=max(s,a[i+1]-a[i]);
}
return s;
}
l=0;
r=1e18-1;
MinMax(l,r,&x,&y);
if(n==2)
{
return y-x;
}
gap=(y-x+n-2)/(n-1);
l=x+1;
mx=x;
//printf("%lld,%lld\n",x,y);
while(1)
{
r=min(l+gap-1,y-1);
//printf("(%lld,%lld)\n",l,r);
MinMax(l,r,&z,&w);
if(z==-1)
{
l+=gap;
if(l>=y)
break;
continue;
}
s=max(s,z-mx);
mx=w;
l+=gap;
if(l>=y)
break;
}
s=max(s,y-mx);
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
2680 KB |
Output is correct |
17 |
Correct |
10 ms |
2692 KB |
Output is correct |
18 |
Correct |
8 ms |
2696 KB |
Output is correct |
19 |
Correct |
9 ms |
2700 KB |
Output is correct |
20 |
Correct |
7 ms |
2848 KB |
Output is correct |
21 |
Correct |
31 ms |
3496 KB |
Output is correct |
22 |
Correct |
32 ms |
3276 KB |
Output is correct |
23 |
Correct |
31 ms |
3268 KB |
Output is correct |
24 |
Correct |
31 ms |
3524 KB |
Output is correct |
25 |
Correct |
27 ms |
3440 KB |
Output is correct |
26 |
Correct |
31 ms |
3272 KB |
Output is correct |
27 |
Correct |
30 ms |
3264 KB |
Output is correct |
28 |
Correct |
31 ms |
3272 KB |
Output is correct |
29 |
Correct |
36 ms |
3252 KB |
Output is correct |
30 |
Correct |
26 ms |
3268 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
11 ms |
652 KB |
Output is correct |
17 |
Correct |
10 ms |
648 KB |
Output is correct |
18 |
Correct |
10 ms |
644 KB |
Output is correct |
19 |
Correct |
10 ms |
652 KB |
Output is correct |
20 |
Correct |
6 ms |
628 KB |
Output is correct |
21 |
Correct |
42 ms |
1216 KB |
Output is correct |
22 |
Correct |
42 ms |
1216 KB |
Output is correct |
23 |
Correct |
42 ms |
1232 KB |
Output is correct |
24 |
Correct |
41 ms |
1212 KB |
Output is correct |
25 |
Correct |
43 ms |
1212 KB |
Output is correct |
26 |
Correct |
42 ms |
1224 KB |
Output is correct |
27 |
Correct |
41 ms |
1216 KB |
Output is correct |
28 |
Correct |
41 ms |
1212 KB |
Output is correct |
29 |
Correct |
44 ms |
1216 KB |
Output is correct |
30 |
Correct |
24 ms |
1176 KB |
Output is correct |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |