# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
712714 |
2023-03-19T14:18:25 Z |
tht2005 |
Gap (APIO16_gap) |
C++17 |
|
62 ms |
6420 KB |
#include "gap.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <utility>
long long findGap(int T, int N) {
if(N == 1) {
return 0;
}
if(T == 1) {
long long LF, RT;
MinMax(0, 1LL << 60, &LF, &RT);
long long res = (N == 2) ? (RT - LF) : 0;
for(int l = 1, r = N - 2; l <= r; ++l, --r) {
long long LF_old = LF, RT_old = RT;
MinMax(LF_old + 1, RT_old - 1, &LF, &RT);
res = std::max(res, std::max(LF - LF_old, RT_old - RT));
if(l + 1 == r) {
res = std::max(res, RT - LF);
}
}
return res;
}
long long LF, RT;
MinMax(0, 1LL << 60, &LF, &RT);
if(N == 2) {
return RT - LF;
}
long long BLK = (RT - LF + 1) / (N - 1);
std::vector<std::pair<long long, long long>> segment(N - 1);
long long tmp = LF;
for(int i = 0; i < N - 1; ++i) {
segment[i].first = tmp;
segment[i].second = tmp + BLK - 1;
tmp += BLK;
}
segment.back().second = RT;
std::vector<std::pair<long long, long long>> range_(N - 1);
for(int i = 0; i < N - 1; ++i) {
MinMax(segment[i].first, segment[i].second, &range_[i].first, &range_[i].second);
}
std::vector<std::pair<long long, long long>> r_;
for(int i = 0; i < N - 1; ++i) {
if(range_[i].first != -1) {
r_.push_back(range_[i]);
}
}
long long res = BLK;
for(int i = 0; i + 1 < (int)r_.size(); ++i) {
res = std::max(res, r_[i + 1].first - r_[i].second);
}
return res;
}
# |
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 |
304 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 |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 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 |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
13 ms |
432 KB |
Output is correct |
17 |
Correct |
12 ms |
512 KB |
Output is correct |
18 |
Correct |
9 ms |
428 KB |
Output is correct |
19 |
Correct |
9 ms |
464 KB |
Output is correct |
20 |
Correct |
7 ms |
492 KB |
Output is correct |
21 |
Correct |
35 ms |
968 KB |
Output is correct |
22 |
Correct |
36 ms |
1056 KB |
Output is correct |
23 |
Correct |
43 ms |
968 KB |
Output is correct |
24 |
Correct |
37 ms |
1104 KB |
Output is correct |
25 |
Correct |
30 ms |
1100 KB |
Output is correct |
26 |
Correct |
34 ms |
1060 KB |
Output is correct |
27 |
Correct |
37 ms |
1064 KB |
Output is correct |
28 |
Correct |
42 ms |
1084 KB |
Output is correct |
29 |
Correct |
36 ms |
1084 KB |
Output is correct |
30 |
Correct |
30 ms |
1104 KB |
Output is correct |
31 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
1576 KB |
Output is correct |
17 |
Correct |
13 ms |
1652 KB |
Output is correct |
18 |
Correct |
13 ms |
1648 KB |
Output is correct |
19 |
Correct |
13 ms |
1580 KB |
Output is correct |
20 |
Correct |
6 ms |
1232 KB |
Output is correct |
21 |
Correct |
53 ms |
5304 KB |
Output is correct |
22 |
Correct |
58 ms |
5280 KB |
Output is correct |
23 |
Correct |
50 ms |
5372 KB |
Output is correct |
24 |
Correct |
54 ms |
5260 KB |
Output is correct |
25 |
Correct |
62 ms |
6420 KB |
Output is correct |
26 |
Correct |
58 ms |
5364 KB |
Output is correct |
27 |
Correct |
52 ms |
5272 KB |
Output is correct |
28 |
Correct |
56 ms |
5300 KB |
Output is correct |
29 |
Correct |
51 ms |
5276 KB |
Output is correct |
30 |
Correct |
30 ms |
4352 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |