#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 6;
ll a[maxn];
long long findGap(int T, int N)
{
int n = N;
if(T == 1){
ll u = 0 - 1 , v = (ll)1e18 + 1;
for(int i = 1 , j = n ; i <= j ; ++i , --j){
MinMax(u + 1 , v - 1 , &a[i] , &a[j]);
u = a[i] , v = a[j];
}
ll res = 0;
for(int i = 2 ; i <= n ; ++i){
res = max(res , a[i] - a[i - 1]);
}
return res;
}
else{
ll u = 0 , v = 1e18;
MinMax(u , v , &u , &v);
ll gap = (v - u) / (n - 1);
a[1] = u;
ll res = gap;
vector<ll> val = {u , v};
for( ; u < v ; u += gap + 1){
ll x , y;MinMax(u , u + gap , &x, &y);
if(x == -1)continue;
val.push_back(x);
val.push_back(y);
}
sort(val.begin(),val.end());
for(int i = 1 ; i < (int)val.size() ; ++i)res = max(res , val[i] - val[i - 1]);
return res;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 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 |
396 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 |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
3 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 |
3 ms |
380 KB |
Output is correct |
16 |
Correct |
16 ms |
1144 KB |
Output is correct |
17 |
Correct |
15 ms |
1144 KB |
Output is correct |
18 |
Correct |
15 ms |
1144 KB |
Output is correct |
19 |
Correct |
15 ms |
1272 KB |
Output is correct |
20 |
Correct |
12 ms |
888 KB |
Output is correct |
21 |
Correct |
57 ms |
2808 KB |
Output is correct |
22 |
Correct |
55 ms |
2680 KB |
Output is correct |
23 |
Correct |
55 ms |
2680 KB |
Output is correct |
24 |
Correct |
57 ms |
2680 KB |
Output is correct |
25 |
Correct |
47 ms |
2680 KB |
Output is correct |
26 |
Correct |
55 ms |
2652 KB |
Output is correct |
27 |
Correct |
56 ms |
2684 KB |
Output is correct |
28 |
Correct |
54 ms |
2680 KB |
Output is correct |
29 |
Correct |
54 ms |
2680 KB |
Output is correct |
30 |
Correct |
40 ms |
2552 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 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 |
3 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 |
3 ms |
504 KB |
Output is correct |
16 |
Correct |
20 ms |
1400 KB |
Output is correct |
17 |
Correct |
20 ms |
1400 KB |
Output is correct |
18 |
Correct |
20 ms |
1428 KB |
Output is correct |
19 |
Correct |
21 ms |
1400 KB |
Output is correct |
20 |
Correct |
10 ms |
888 KB |
Output is correct |
21 |
Correct |
77 ms |
3052 KB |
Output is correct |
22 |
Correct |
77 ms |
3036 KB |
Output is correct |
23 |
Correct |
80 ms |
3056 KB |
Output is correct |
24 |
Correct |
77 ms |
3052 KB |
Output is correct |
25 |
Correct |
73 ms |
4076 KB |
Output is correct |
26 |
Correct |
77 ms |
3064 KB |
Output is correct |
27 |
Correct |
76 ms |
2992 KB |
Output is correct |
28 |
Correct |
78 ms |
3088 KB |
Output is correct |
29 |
Correct |
80 ms |
3052 KB |
Output is correct |
30 |
Correct |
38 ms |
2168 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |