# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
344091 |
2021-01-05T06:31:39 Z |
milleniumEeee |
Gap (APIO16_gap) |
C++17 |
|
70 ms |
2452 KB |
#include "gap.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
//MinMax(long long s, long long t, long long *mn, long long *mx)
const ll INF = (ll)1e18;
const int MAXN = (int)1e5 + 5;
ll a[MAXN];
long long findGap(int type, int n)
{
if (n == 2) {
ll mn, mx;
MinMax(0, INF, &mn, &mx);
return mx - mn;
}
if (type == 1) {
ll mn, mx;
MinMax(0, INF, &mn, &mx);
int l = 1, r = n;
a[l] = mn;
a[r] = mx;
while (r - l - 1 >= 2) {
MinMax(mn + 1, mx - 1, &mn, &mx);
a[++l] = mn;
a[--r] = mx;
}
if (r - l + 1 == 3) {
MinMax(mn + 1, mx - 1, &mn, &mx);
a[l + 1] = mn;
}
ll ans = 0;
for (int i = 1; i < n; i++) {
ans = max(ans, a[i + 1] - a[i]);
}
return ans;
} else {
ll ans = 0;
ll mn, mx;
vector <ll> arr;
MinMax(0, INF, &mn, &mx);
ll k = (mx - mn + n - 2ll) / (n - 1ll);
arr.push_back(mn);
arr.push_back(mx);
ll MN = mn, MX = mx;
for (ll pos = MN + 1; pos <= MX - 1; pos += k) {
ll l = pos;
ll r = min(MX - 1, pos + k - 1);
MinMax(l, r, &mn, &mx);
if (mn != -1 && mx != -1) {
if (mn == mx) {
arr.push_back(mn);
} else {
arr.push_back(mn);
arr.push_back(mx);
}
}
}
sort(arr.begin(), arr.end());
for (int i = 0; i + 1 < (int)arr.size(); i++) {
ans = max(ans, arr[i + 1] - arr[i]);
}
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
11 ms |
876 KB |
Output is correct |
17 |
Correct |
11 ms |
748 KB |
Output is correct |
18 |
Correct |
13 ms |
748 KB |
Output is correct |
19 |
Correct |
11 ms |
748 KB |
Output is correct |
20 |
Correct |
10 ms |
748 KB |
Output is correct |
21 |
Correct |
43 ms |
1900 KB |
Output is correct |
22 |
Correct |
43 ms |
1900 KB |
Output is correct |
23 |
Correct |
43 ms |
1900 KB |
Output is correct |
24 |
Correct |
43 ms |
1900 KB |
Output is correct |
25 |
Correct |
39 ms |
2028 KB |
Output is correct |
26 |
Correct |
43 ms |
1900 KB |
Output is correct |
27 |
Correct |
44 ms |
1976 KB |
Output is correct |
28 |
Correct |
43 ms |
1900 KB |
Output is correct |
29 |
Correct |
45 ms |
2060 KB |
Output is correct |
30 |
Correct |
35 ms |
1900 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
0 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
15 ms |
876 KB |
Output is correct |
17 |
Correct |
15 ms |
876 KB |
Output is correct |
18 |
Correct |
15 ms |
876 KB |
Output is correct |
19 |
Correct |
16 ms |
876 KB |
Output is correct |
20 |
Correct |
8 ms |
620 KB |
Output is correct |
21 |
Correct |
62 ms |
2276 KB |
Output is correct |
22 |
Correct |
63 ms |
2276 KB |
Output is correct |
23 |
Correct |
63 ms |
2452 KB |
Output is correct |
24 |
Correct |
63 ms |
2276 KB |
Output is correct |
25 |
Correct |
63 ms |
2276 KB |
Output is correct |
26 |
Correct |
63 ms |
2404 KB |
Output is correct |
27 |
Correct |
70 ms |
2276 KB |
Output is correct |
28 |
Correct |
62 ms |
2276 KB |
Output is correct |
29 |
Correct |
64 ms |
2276 KB |
Output is correct |
30 |
Correct |
35 ms |
1516 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |