# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
61204 |
2018-07-25T11:07:53 Z |
Eae02 |
Gap (APIO16_gap) |
C++14 |
|
100 ms |
2284 KB |
#include "gap.h"
#include <bits/stdc++.h>
using ll = long long;
ll gMaxDiff = 0;
long long findGap(int T, int N)
{
if (T == 1)
{
ll min = 0;
ll max = 1000000000000000000;
std::vector<ll> numbers(N);
for (int i = 0; 2 * i < N; i++)
{
ll nextMin, nextMax;
MinMax(min, max, &nextMin, &nextMax);
numbers[i] = nextMin;
numbers[numbers.size() - i - 1] = nextMax;
min = nextMin + 1;
max = nextMax - 1;
}
for (int i = 1; i < N; i++)
{
gMaxDiff = std::max(gMaxDiff, numbers[i] - numbers[i - 1]);
}
}
else
{
ll min, max;
MinMax(0, 1000000000000000000, &min, &max);
if (N <= 2)
return max - min;
ll step = std::ceil((max - min) / (double)(N - 2));
ll prev = min;
for (ll i = min; i < max; i += step)
{
ll nMin, nMax;
MinMax(i + 1, i + step, &nMin, &nMax);
//std::cout << nMin << " " << nMax << ", " << nMin - prev << std::endl;
if (nMin == -1)
continue;
gMaxDiff = std::max(gMaxDiff, nMin - prev);
prev = nMax;
}
gMaxDiff = std::max(gMaxDiff, max - prev);
//maxDiff(min, max);
}
return gMaxDiff;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
4 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
596 KB |
Output is correct |
6 |
Correct |
2 ms |
612 KB |
Output is correct |
7 |
Correct |
2 ms |
612 KB |
Output is correct |
8 |
Correct |
2 ms |
652 KB |
Output is correct |
9 |
Correct |
2 ms |
652 KB |
Output is correct |
10 |
Correct |
3 ms |
652 KB |
Output is correct |
11 |
Correct |
4 ms |
652 KB |
Output is correct |
12 |
Correct |
4 ms |
652 KB |
Output is correct |
13 |
Correct |
3 ms |
652 KB |
Output is correct |
14 |
Correct |
4 ms |
652 KB |
Output is correct |
15 |
Correct |
4 ms |
652 KB |
Output is correct |
16 |
Correct |
16 ms |
980 KB |
Output is correct |
17 |
Correct |
17 ms |
1004 KB |
Output is correct |
18 |
Correct |
18 ms |
1132 KB |
Output is correct |
19 |
Correct |
17 ms |
1132 KB |
Output is correct |
20 |
Correct |
13 ms |
1132 KB |
Output is correct |
21 |
Correct |
83 ms |
2156 KB |
Output is correct |
22 |
Correct |
81 ms |
2156 KB |
Output is correct |
23 |
Correct |
80 ms |
2156 KB |
Output is correct |
24 |
Correct |
67 ms |
2164 KB |
Output is correct |
25 |
Correct |
56 ms |
2164 KB |
Output is correct |
26 |
Correct |
76 ms |
2164 KB |
Output is correct |
27 |
Correct |
78 ms |
2164 KB |
Output is correct |
28 |
Correct |
86 ms |
2284 KB |
Output is correct |
29 |
Correct |
83 ms |
2284 KB |
Output is correct |
30 |
Correct |
48 ms |
2284 KB |
Output is correct |
31 |
Correct |
4 ms |
2284 KB |
Output is correct |
32 |
Correct |
3 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2284 KB |
Output is correct |
2 |
Correct |
3 ms |
2284 KB |
Output is correct |
3 |
Correct |
3 ms |
2284 KB |
Output is correct |
4 |
Correct |
3 ms |
2284 KB |
Output is correct |
5 |
Correct |
2 ms |
2284 KB |
Output is correct |
6 |
Correct |
3 ms |
2284 KB |
Output is correct |
7 |
Correct |
3 ms |
2284 KB |
Output is correct |
8 |
Correct |
2 ms |
2284 KB |
Output is correct |
9 |
Correct |
3 ms |
2284 KB |
Output is correct |
10 |
Correct |
4 ms |
2284 KB |
Output is correct |
11 |
Correct |
5 ms |
2284 KB |
Output is correct |
12 |
Correct |
4 ms |
2284 KB |
Output is correct |
13 |
Correct |
5 ms |
2284 KB |
Output is correct |
14 |
Correct |
5 ms |
2284 KB |
Output is correct |
15 |
Correct |
3 ms |
2284 KB |
Output is correct |
16 |
Correct |
28 ms |
2284 KB |
Output is correct |
17 |
Correct |
26 ms |
2284 KB |
Output is correct |
18 |
Correct |
24 ms |
2284 KB |
Output is correct |
19 |
Correct |
25 ms |
2284 KB |
Output is correct |
20 |
Correct |
14 ms |
2284 KB |
Output is correct |
21 |
Correct |
100 ms |
2284 KB |
Output is correct |
22 |
Correct |
97 ms |
2284 KB |
Output is correct |
23 |
Correct |
84 ms |
2284 KB |
Output is correct |
24 |
Correct |
85 ms |
2284 KB |
Output is correct |
25 |
Correct |
80 ms |
2284 KB |
Output is correct |
26 |
Correct |
86 ms |
2284 KB |
Output is correct |
27 |
Correct |
89 ms |
2284 KB |
Output is correct |
28 |
Correct |
86 ms |
2284 KB |
Output is correct |
29 |
Correct |
88 ms |
2284 KB |
Output is correct |
30 |
Correct |
46 ms |
2284 KB |
Output is correct |
31 |
Correct |
3 ms |
2284 KB |
Output is correct |
32 |
Correct |
2 ms |
2284 KB |
Output is correct |