#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;
#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)
int t, n;
vi a, b;
long long findGap(int T, int n){
if(T==2){
long long int a1=0, an=0;
MinMax(0, (ll)1e18, &a1, &an);
long long ans = (an - a1) / (n-1);
long long start = a1 + 1;
long long ansstart=a1;
while(start <= an){
long long a=0, b=0;
MinMax(start, start + ans, &a, &b);
if(a==-1){
start += ans + 1;
}
else{
ans = max(ans, a-ansstart);
ansstart = b;
start = b+1;
}
}
return ans;
}
else{
ll a[n] = {};
MinMax(0, (ll)(1e18), &a[0], &a[n-1]);
FORi(i,1,(n+1)/2){
MinMax(a[i-1]+1, a[n-i]-1, &a[i], &a[n-i-1]);
}
ll ans = a[1]-a[0];
FOR(i,n-1){
ans = max(ans, a[i+1]-a[i]);
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
9 ms |
696 KB |
Output is correct |
17 |
Correct |
10 ms |
584 KB |
Output is correct |
18 |
Correct |
10 ms |
676 KB |
Output is correct |
19 |
Correct |
10 ms |
600 KB |
Output is correct |
20 |
Correct |
7 ms |
584 KB |
Output is correct |
21 |
Correct |
39 ms |
1748 KB |
Output is correct |
22 |
Correct |
42 ms |
1848 KB |
Output is correct |
23 |
Correct |
44 ms |
1948 KB |
Output is correct |
24 |
Correct |
35 ms |
1820 KB |
Output is correct |
25 |
Correct |
32 ms |
1864 KB |
Output is correct |
26 |
Correct |
35 ms |
1820 KB |
Output is correct |
27 |
Correct |
46 ms |
1940 KB |
Output is correct |
28 |
Correct |
36 ms |
1820 KB |
Output is correct |
29 |
Correct |
37 ms |
1728 KB |
Output is correct |
30 |
Correct |
30 ms |
1824 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
7 ms |
456 KB |
Output is correct |
17 |
Correct |
9 ms |
420 KB |
Output is correct |
18 |
Correct |
7 ms |
416 KB |
Output is correct |
19 |
Correct |
9 ms |
456 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
24 ms |
1044 KB |
Output is correct |
22 |
Correct |
38 ms |
1052 KB |
Output is correct |
23 |
Correct |
24 ms |
1036 KB |
Output is correct |
24 |
Correct |
22 ms |
1052 KB |
Output is correct |
25 |
Correct |
54 ms |
1076 KB |
Output is correct |
26 |
Correct |
25 ms |
1048 KB |
Output is correct |
27 |
Correct |
24 ms |
1072 KB |
Output is correct |
28 |
Correct |
24 ms |
960 KB |
Output is correct |
29 |
Correct |
30 ms |
1036 KB |
Output is correct |
30 |
Correct |
18 ms |
1016 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |