# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
775515 |
2023-07-06T13:13:03 Z |
anaduguleanu |
Gap (APIO16_gap) |
C++14 |
|
70 ms |
5832 KB |
#include <iostream>
#include <set>
#include "gap.h"
#define INF 1000000000000000000
using namespace std;
set <long long> s;
long long findGap(int T, int N)
{
if (T == 1)
{
long long minimum, maximum;
MinMax(1, INF, &minimum, &maximum);
s.insert(minimum);
s.insert(maximum);
for (int i = 1; i < (N + 1) >> 1; i++)
{
long long val1, val2;
MinMax(minimum + 1, maximum - 1, &val1, &val2);
s.insert(val1);
s.insert(val2);
minimum = val1;
maximum = val2;
}
long long maxGap = 0, last = minimum;
for (auto it : s)
{
maxGap = max(maxGap, it - last);
last = it;
}
return maxGap;
}
else
{
long long minimum, maximum;
MinMax(1, INF, &minimum, &maximum);
long long gapLength;
if ((maximum - minimum) % (N - 1) == 0)
gapLength = (maximum - minimum) / (N - 1);
else
gapLength = (maximum - minimum) / (N - 1) + 1;
for (long long i = minimum + 1; i <= maximum - 1; i = i + gapLength)
{
long long val1, val2;
MinMax(i, i + gapLength - 1, &val1, &val2);
s.insert(val1);
s.insert(val2);
}
s.erase(-1);
long long maxGap = 0, last = minimum;
for (auto it : s)
{
maxGap = max(maxGap, it - last);
last = it;
}
return maxGap;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
1656 KB |
Output is correct |
17 |
Correct |
11 ms |
1640 KB |
Output is correct |
18 |
Correct |
11 ms |
1584 KB |
Output is correct |
19 |
Correct |
10 ms |
1616 KB |
Output is correct |
20 |
Correct |
9 ms |
1612 KB |
Output is correct |
21 |
Correct |
49 ms |
5724 KB |
Output is correct |
22 |
Correct |
47 ms |
5752 KB |
Output is correct |
23 |
Correct |
44 ms |
5752 KB |
Output is correct |
24 |
Correct |
46 ms |
5704 KB |
Output is correct |
25 |
Correct |
40 ms |
5780 KB |
Output is correct |
26 |
Correct |
49 ms |
5688 KB |
Output is correct |
27 |
Correct |
50 ms |
5704 KB |
Output is correct |
28 |
Correct |
44 ms |
5764 KB |
Output is correct |
29 |
Correct |
44 ms |
5680 KB |
Output is correct |
30 |
Correct |
40 ms |
5688 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
14 ms |
1536 KB |
Output is correct |
17 |
Correct |
14 ms |
1488 KB |
Output is correct |
18 |
Correct |
13 ms |
1476 KB |
Output is correct |
19 |
Correct |
14 ms |
1628 KB |
Output is correct |
20 |
Correct |
5 ms |
464 KB |
Output is correct |
21 |
Correct |
58 ms |
5276 KB |
Output is correct |
22 |
Correct |
70 ms |
5212 KB |
Output is correct |
23 |
Correct |
63 ms |
5228 KB |
Output is correct |
24 |
Correct |
60 ms |
5204 KB |
Output is correct |
25 |
Correct |
64 ms |
5832 KB |
Output is correct |
26 |
Correct |
58 ms |
5280 KB |
Output is correct |
27 |
Correct |
62 ms |
5180 KB |
Output is correct |
28 |
Correct |
65 ms |
5200 KB |
Output is correct |
29 |
Correct |
69 ms |
5152 KB |
Output is correct |
30 |
Correct |
27 ms |
1888 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |