#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<ll, int> ii;
const int mod = (int) 1e9 + 7;
const ll inf = 1LL << 60;
const int maxn = (int) 1e5 + 5;
const ld eps = 1e-9;
vector<ll> a, b;
ll l[maxn], r[maxn];
ll findGap(int T, int N) {
a.resize(N + 1, 0);
b.resize(N + 1, 0);
MinMax(0, inf, &a[0], &a[N]);
b[0] = a[0]; b[N] = a[N];
ll len = a[N] - a[0] - 1;
ll g = min(len, 1LL * N - 1);
ll sg = len % g;
ll bg = g - sg;
l[0] = r[0] = a[0];
a[g + 1] = a[N];
b[g + 1] = b[N];
rep(i, 1, g + 1) {
l[i] = r[i - 1] + 1;
if(i <= sg) r[i] = l[i] + (len / g) - 1;
else r[i] = l[i] + (len / g);
MinMax(l[i], r[i], &a[i], &b[i]);
}
ll res = 1;
int j = 0;
rep(i, 0, g + 2) {
res = max(res, a[i] - b[j]);
if(a[i] == -1 && b[i] == -1) continue;
j = i;
}
return res;
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:30:8: warning: unused variable 'bg' [-Wunused-variable]
ll bg = g - sg;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
16 |
Incorrect |
19 ms |
7104 KB |
Output isn't correct |
17 |
Incorrect |
16 ms |
7104 KB |
Output isn't correct |
18 |
Incorrect |
16 ms |
7104 KB |
Output isn't correct |
19 |
Incorrect |
16 ms |
7104 KB |
Output isn't correct |
20 |
Incorrect |
6 ms |
7104 KB |
Output isn't correct |
21 |
Incorrect |
76 ms |
8280 KB |
Output isn't correct |
22 |
Incorrect |
79 ms |
8280 KB |
Output isn't correct |
23 |
Incorrect |
69 ms |
8280 KB |
Output isn't correct |
24 |
Incorrect |
66 ms |
8280 KB |
Output isn't correct |
25 |
Incorrect |
73 ms |
8280 KB |
Output isn't correct |
26 |
Incorrect |
79 ms |
8280 KB |
Output isn't correct |
27 |
Incorrect |
79 ms |
8280 KB |
Output isn't correct |
28 |
Incorrect |
73 ms |
8280 KB |
Output isn't correct |
29 |
Incorrect |
79 ms |
8280 KB |
Output isn't correct |
30 |
Incorrect |
39 ms |
8280 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
6712 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
6712 KB |
Output is correct |
2 |
Correct |
0 ms |
6712 KB |
Output is correct |
3 |
Correct |
0 ms |
6712 KB |
Output is correct |
4 |
Correct |
0 ms |
6712 KB |
Output is correct |
5 |
Correct |
0 ms |
6712 KB |
Output is correct |
6 |
Correct |
0 ms |
6712 KB |
Output is correct |
7 |
Correct |
0 ms |
6712 KB |
Output is correct |
8 |
Correct |
0 ms |
6712 KB |
Output is correct |
9 |
Correct |
0 ms |
6712 KB |
Output is correct |
10 |
Correct |
0 ms |
6712 KB |
Output is correct |
11 |
Correct |
0 ms |
6712 KB |
Output is correct |
12 |
Correct |
0 ms |
6712 KB |
Output is correct |
13 |
Correct |
0 ms |
6712 KB |
Output is correct |
14 |
Correct |
0 ms |
6712 KB |
Output is correct |
15 |
Correct |
0 ms |
6712 KB |
Output is correct |
16 |
Correct |
26 ms |
7104 KB |
Output is correct |
17 |
Correct |
16 ms |
7104 KB |
Output is correct |
18 |
Correct |
13 ms |
7104 KB |
Output is correct |
19 |
Correct |
16 ms |
7104 KB |
Output is correct |
20 |
Correct |
16 ms |
7104 KB |
Output is correct |
21 |
Correct |
66 ms |
8280 KB |
Output is correct |
22 |
Correct |
69 ms |
8280 KB |
Output is correct |
23 |
Correct |
76 ms |
8280 KB |
Output is correct |
24 |
Correct |
76 ms |
8280 KB |
Output is correct |
25 |
Correct |
69 ms |
8280 KB |
Output is correct |
26 |
Correct |
69 ms |
8280 KB |
Output is correct |
27 |
Correct |
79 ms |
8280 KB |
Output is correct |
28 |
Correct |
103 ms |
8280 KB |
Output is correct |
29 |
Correct |
76 ms |
8280 KB |
Output is correct |
30 |
Correct |
29 ms |
8280 KB |
Output is correct |
31 |
Correct |
0 ms |
6712 KB |
Output is correct |
32 |
Correct |
0 ms |
6712 KB |
Output is correct |