#include <iostream>
#include "gap.h"
using namespace std;
const long long MAXN = 1e6+5;
long long arr[MAXN];
long long findGap(int T,int N){
if(T == 1){
long long a = 1;
long long b = 1e18;
long long l = 0;
long long r = N-1;
long long mn,mx;
long long total = 0;
while(total<N){
MinMax(a, b, &mn, &mx);
arr[l] = mn;
arr[r] = mx;
l++;
r--;
total+=2;
a = mn+1;
b = mx-1;
}
long long diff = 0;
for(long long i=0;i<N-1;i++){
diff = max(diff,arr[i+1]-arr[i]);
}
return diff;
}else{
long long a = 1;
long long b = 1e18;
long long mn,mx;
MinMax(a, b, &mn, &mx);
arr[0] = mn;
arr[N-1] = mx;
long long diff = ((mx-mn-1)/(N-1))+1;
long long l = mn+1;
long long r = mn+diff;
long long ans = 0;
long long prv = mn;
for(long long i=0;i<N-1;i++){
MinMax(l, l+diff-1, &mn, &mx);
if(mn>=0){
ans = max(ans,mn-prv);
prv = mx;
}
l+=diff;
r+=diff;
}
return max(ans,mx-r);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 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 |
384 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 |
412 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
14 ms |
1152 KB |
Output is correct |
17 |
Correct |
15 ms |
1152 KB |
Output is correct |
18 |
Correct |
15 ms |
1152 KB |
Output is correct |
19 |
Correct |
18 ms |
1152 KB |
Output is correct |
20 |
Correct |
14 ms |
768 KB |
Output is correct |
21 |
Correct |
50 ms |
2936 KB |
Output is correct |
22 |
Correct |
49 ms |
2808 KB |
Output is correct |
23 |
Correct |
49 ms |
2808 KB |
Output is correct |
24 |
Correct |
49 ms |
2808 KB |
Output is correct |
25 |
Correct |
64 ms |
2424 KB |
Output is correct |
26 |
Correct |
60 ms |
2908 KB |
Output is correct |
27 |
Correct |
44 ms |
2936 KB |
Output is correct |
28 |
Correct |
46 ms |
2808 KB |
Output is correct |
29 |
Correct |
48 ms |
2768 KB |
Output is correct |
30 |
Correct |
35 ms |
2424 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 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 |
3 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 |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 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 |
18 ms |
896 KB |
Output is correct |
17 |
Correct |
18 ms |
896 KB |
Output is correct |
18 |
Correct |
18 ms |
896 KB |
Output is correct |
19 |
Correct |
21 ms |
896 KB |
Output is correct |
20 |
Correct |
11 ms |
640 KB |
Output is correct |
21 |
Correct |
66 ms |
2040 KB |
Output is correct |
22 |
Correct |
68 ms |
2040 KB |
Output is correct |
23 |
Correct |
67 ms |
2024 KB |
Output is correct |
24 |
Correct |
74 ms |
2040 KB |
Output is correct |
25 |
Correct |
62 ms |
1664 KB |
Output is correct |
26 |
Correct |
62 ms |
2040 KB |
Output is correct |
27 |
Correct |
70 ms |
2040 KB |
Output is correct |
28 |
Correct |
65 ms |
2048 KB |
Output is correct |
29 |
Correct |
62 ms |
2040 KB |
Output is correct |
30 |
Correct |
36 ms |
1664 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |