#include "gap.h"
#include <algorithm>
using namespace std;
long long A[1000*100+1];
long long findGap(int T, int N)
{
if(T == 1){
long long s = 0;
long long t = 1000000000;
t*=t;
long long nax;
long long as = 0;
int tl = 1;
int tr = N;
long long l = s;
long long r = t;
while(tl<=tr){
long long ans;
long long mn,mx;
MinMax(l,r,&mn,&mx);
A[tl] = mn;
A[tr] = mx;
tl++;
tr--;
l = mn+1;
r = mx-1;
}
for(int i = 1;i<N;i++){
as = max(as,A[i+1]-A[i]);
}
// cout<<as<<endl;
return as;
}
long long s = 0;
long long t = 1000000000;
t*=t;
long long mn,mx;
MinMax(s,t,&mn,&mx);
long long as = 0;
long long sz = (mx-mn-1)/(N-1);
if(sz<100) sz++;
long long nax = mn;
s = mn+1;
t = mn+sz;
while(t<mx){
long long a,b;
MinMax(s,t,&a,&b);
if(a == -1 && b == -1){
if(t == mx-1) break;
s = s+sz;
t = t+sz;
continue;
}
if(nax!=-1){
as = max(as,a-nax);
}
nax = b;
if(t == mx-1) break;
s+=sz;
t+=sz;
t = min(t,mx-1);
}
if(nax){
as = max(as,mx-nax);
}
// cout<<as<<endl;
return as;
return 0;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:18:19: warning: unused variable 'ans' [-Wunused-variable]
long long ans;
^~~
gap.cpp:11:15: warning: unused variable 'nax' [-Wunused-variable]
long long nax;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
15 ms |
768 KB |
Output is correct |
17 |
Correct |
15 ms |
640 KB |
Output is correct |
18 |
Correct |
14 ms |
640 KB |
Output is correct |
19 |
Correct |
14 ms |
768 KB |
Output is correct |
20 |
Correct |
12 ms |
740 KB |
Output is correct |
21 |
Correct |
49 ms |
1908 KB |
Output is correct |
22 |
Correct |
61 ms |
1912 KB |
Output is correct |
23 |
Correct |
49 ms |
1912 KB |
Output is correct |
24 |
Correct |
57 ms |
1912 KB |
Output is correct |
25 |
Correct |
46 ms |
1912 KB |
Output is correct |
26 |
Correct |
52 ms |
1912 KB |
Output is correct |
27 |
Correct |
50 ms |
1912 KB |
Output is correct |
28 |
Correct |
51 ms |
1912 KB |
Output is correct |
29 |
Correct |
53 ms |
1912 KB |
Output is correct |
30 |
Correct |
44 ms |
1912 KB |
Output is correct |
31 |
Correct |
2 ms |
256 KB |
Output is correct |
32 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
256 KB |
Output is correct |
13 |
Correct |
3 ms |
256 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
19 ms |
640 KB |
Output is correct |
17 |
Correct |
19 ms |
512 KB |
Output is correct |
18 |
Correct |
19 ms |
512 KB |
Output is correct |
19 |
Correct |
20 ms |
512 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
68 ms |
1144 KB |
Output is correct |
22 |
Correct |
88 ms |
1144 KB |
Output is correct |
23 |
Correct |
74 ms |
1204 KB |
Output is correct |
24 |
Correct |
65 ms |
1160 KB |
Output is correct |
25 |
Correct |
64 ms |
1152 KB |
Output is correct |
26 |
Correct |
72 ms |
1272 KB |
Output is correct |
27 |
Correct |
68 ms |
1128 KB |
Output is correct |
28 |
Correct |
83 ms |
1096 KB |
Output is correct |
29 |
Correct |
83 ms |
1148 KB |
Output is correct |
30 |
Correct |
37 ms |
1120 KB |
Output is correct |
31 |
Correct |
2 ms |
256 KB |
Output is correct |
32 |
Correct |
2 ms |
256 KB |
Output is correct |