# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
96343 |
2019-02-08T14:40:40 Z |
ShaneOng |
Gap (APIO16_gap) |
C++14 |
|
64 ms |
1276 KB |
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int n){
long long ans=0ll;
if(T==1){
long long l=0ll,r=1000000000000000000ll;
MinMax(l,r,&l,&r);
int temp=2;
for(int x=0;temp<n;x++){
long long newl=-1ll,newr=-1ll;
if(l+1ll<r-1ll)
MinMax(l+1ll,r-1ll,&newl,&newr);
if(newl!=-1ll){
ans=max(ans,max(newl-l,r-newr));
l=newl;
r=newr;
}
temp+=2;
}
if(n==2)
ans=r-l;
}else{
long long l=0ll,r=1000000000000000000ll;
MinMax(l,r,&l,&r);
int temp=2;
long long interv = (r-l+n-2ll)/(n-1ll),pre=l;
for(int x=0;x<n-1;x++){
long long a=l+x*interv+1ll,b=l+(x+1ll)*interv,c,d;
MinMax(a,b,&c,&d);
if(c!=-1ll){
ans=max(ans,d-c);
if(pre!=-1ll)
ans=max(ans,c-pre);
pre=d;
}
}
if(pre!=-1ll)
ans=max(ans,r-pre);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:13: warning: unused variable 'temp' [-Wunused-variable]
int temp=2;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
12 ms |
504 KB |
Output is correct |
17 |
Correct |
13 ms |
504 KB |
Output is correct |
18 |
Correct |
12 ms |
504 KB |
Output is correct |
19 |
Correct |
12 ms |
504 KB |
Output is correct |
20 |
Correct |
9 ms |
504 KB |
Output is correct |
21 |
Correct |
46 ms |
1144 KB |
Output is correct |
22 |
Correct |
47 ms |
1144 KB |
Output is correct |
23 |
Correct |
46 ms |
1144 KB |
Output is correct |
24 |
Correct |
50 ms |
1144 KB |
Output is correct |
25 |
Correct |
39 ms |
1148 KB |
Output is correct |
26 |
Correct |
45 ms |
1144 KB |
Output is correct |
27 |
Correct |
45 ms |
1276 KB |
Output is correct |
28 |
Correct |
47 ms |
1144 KB |
Output is correct |
29 |
Correct |
46 ms |
1160 KB |
Output is correct |
30 |
Correct |
36 ms |
1144 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
18 ms |
504 KB |
Output is correct |
17 |
Correct |
18 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
504 KB |
Output is correct |
19 |
Correct |
16 ms |
504 KB |
Output is correct |
20 |
Correct |
10 ms |
584 KB |
Output is correct |
21 |
Correct |
61 ms |
1272 KB |
Output is correct |
22 |
Correct |
60 ms |
1144 KB |
Output is correct |
23 |
Correct |
64 ms |
1144 KB |
Output is correct |
24 |
Correct |
60 ms |
1144 KB |
Output is correct |
25 |
Correct |
58 ms |
1120 KB |
Output is correct |
26 |
Correct |
61 ms |
1144 KB |
Output is correct |
27 |
Correct |
61 ms |
1144 KB |
Output is correct |
28 |
Correct |
62 ms |
1144 KB |
Output is correct |
29 |
Correct |
61 ms |
1244 KB |
Output is correct |
30 |
Correct |
32 ms |
1144 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
380 KB |
Output is correct |