#include "gap.h"
#include <algorithm>
#include <stdio.h>
using namespace std;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
const ll MINV = 0, MAXV = 1e18;
const int MAX_N = 1e5 + 100;
ll minV, maxV;
ll Nr[MAX_N][2], Ans[MAX_N];
long long findGap(int T, int N)
{
if(T == 1) {
ll ans = 0;
minV = MINV, maxV = MAXV;
int li = 0, ri = N-1;
for(int i=0; i<(N+1)/2; i++) {
ll l, r;
MinMax(minV, maxV, &l, &r);
Ans[li++] = l;
Ans[ri--] = r;
minV = l+1; maxV = r-1;
}
for(int i=0; i+1<N; i++)
ans = max(ans, Ans[i+1] - Ans[i]);
return ans;
}
if(T == 2) {
MinMax(MINV, MAXV, &minV, &maxV);
ll diff = (maxV - minV + N-1) / N;
ll ans = 0, lastR = -1;
for(int i=0; i<N; i++) {
ll l = min(maxV, minV + i * diff);
ll r = min(maxV, minV + (i+1) * diff);
MinMax(l, r, &Nr[i][0], &Nr[i][1]);
// printf("%lld %lld -> %lld %lld\n", l, r, Nr[i][0], Nr[i][1]);
if(Nr[i][0] >= 0) {
ans = max(ans, Nr[i][0] - lastR);
lastR = Nr[i][1];
}
}
return ans;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6588 KB |
Output is correct |
2 |
Correct |
0 ms |
6588 KB |
Output is correct |
3 |
Correct |
0 ms |
6588 KB |
Output is correct |
4 |
Correct |
0 ms |
6588 KB |
Output is correct |
5 |
Correct |
0 ms |
6588 KB |
Output is correct |
6 |
Correct |
0 ms |
6588 KB |
Output is correct |
7 |
Correct |
0 ms |
6588 KB |
Output is correct |
8 |
Correct |
0 ms |
6588 KB |
Output is correct |
9 |
Correct |
0 ms |
6588 KB |
Output is correct |
10 |
Correct |
0 ms |
6588 KB |
Output is correct |
11 |
Correct |
0 ms |
6588 KB |
Output is correct |
12 |
Correct |
0 ms |
6588 KB |
Output is correct |
13 |
Correct |
0 ms |
6588 KB |
Output is correct |
14 |
Correct |
0 ms |
6588 KB |
Output is correct |
15 |
Correct |
0 ms |
6588 KB |
Output is correct |
16 |
Correct |
16 ms |
6588 KB |
Output is correct |
17 |
Correct |
13 ms |
6588 KB |
Output is correct |
18 |
Correct |
13 ms |
6588 KB |
Output is correct |
19 |
Correct |
16 ms |
6588 KB |
Output is correct |
20 |
Correct |
9 ms |
6588 KB |
Output is correct |
21 |
Correct |
66 ms |
6588 KB |
Output is correct |
22 |
Correct |
59 ms |
6588 KB |
Output is correct |
23 |
Correct |
56 ms |
6588 KB |
Output is correct |
24 |
Correct |
76 ms |
6588 KB |
Output is correct |
25 |
Correct |
59 ms |
6588 KB |
Output is correct |
26 |
Correct |
63 ms |
6588 KB |
Output is correct |
27 |
Correct |
59 ms |
6588 KB |
Output is correct |
28 |
Correct |
69 ms |
6588 KB |
Output is correct |
29 |
Correct |
63 ms |
6588 KB |
Output is correct |
30 |
Correct |
43 ms |
6588 KB |
Output is correct |
31 |
Correct |
0 ms |
6588 KB |
Output is correct |
32 |
Correct |
0 ms |
6588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
2 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
3 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
4 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
5 |
Incorrect |
0 ms |
6588 KB |
Output isn't correct |
6 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
7 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
8 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
9 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
10 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
11 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
12 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
13 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
14 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
15 |
Incorrect |
0 ms |
6588 KB |
Output isn't correct |
16 |
Partially correct |
16 ms |
6588 KB |
Partially correct |
17 |
Partially correct |
16 ms |
6588 KB |
Partially correct |
18 |
Partially correct |
13 ms |
6588 KB |
Partially correct |
19 |
Partially correct |
13 ms |
6588 KB |
Partially correct |
20 |
Partially correct |
9 ms |
6588 KB |
Partially correct |
21 |
Partially correct |
79 ms |
6588 KB |
Partially correct |
22 |
Partially correct |
76 ms |
6588 KB |
Partially correct |
23 |
Partially correct |
73 ms |
6588 KB |
Partially correct |
24 |
Partially correct |
79 ms |
6588 KB |
Partially correct |
25 |
Incorrect |
69 ms |
6588 KB |
Output isn't correct |
26 |
Partially correct |
76 ms |
6588 KB |
Partially correct |
27 |
Partially correct |
66 ms |
6588 KB |
Partially correct |
28 |
Partially correct |
73 ms |
6588 KB |
Partially correct |
29 |
Partially correct |
66 ms |
6588 KB |
Partially correct |
30 |
Partially correct |
53 ms |
6588 KB |
Partially correct |
31 |
Partially correct |
0 ms |
6588 KB |
Partially correct |
32 |
Partially correct |
0 ms |
6588 KB |
Partially correct |