# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
594309 |
2022-07-12T10:46:07 Z |
Vanilla |
Gap (APIO16_gap) |
C++17 |
|
69 ms |
7008 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long int64;
int64 findGap(int t, int n){
vector <int64> v;
int64 rs = -1;
if (t == 1) {
int64 l = 0, r = 1e18, mn = -1, mx = -1;
set <int64> s;
vector <int64> p1, p2;
while (s.size() != n) {
MinMax(l, r, &mn, &mx);
if (mn == -1) break;
s.insert(mn);
s.insert(mx);
l = mn + 1, r = mx - 1;
}
for (int64 i: s) v.push_back(i);
for (int i = 1; i < n; i++){
rs = max(rs, v[i] - v[i-1]);
}
}
else {
int64 mn = -1, mx = -1;
MinMax(0, 1e18, &mn, &mx);
if (n == 2) return mx - mn;
int64 x = (mx - mn) / (n - 1);
int64 last = mn;
for (int64 i = mn; i < mx; i+=x + 1) {
int64 nx, ny;
MinMax(i, i + x, &nx, &ny);
if (nx == -1) continue;
rs = max(rs, nx - last);
last = ny;
}
}
return rs;
}
Compilation message
gap.cpp: In function 'int64 findGap(int, int)':
gap.cpp:13:19: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
13 | while (s.size() != n) {
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
304 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 |
13 ms |
2004 KB |
Output is correct |
17 |
Correct |
16 ms |
2024 KB |
Output is correct |
18 |
Correct |
17 ms |
2040 KB |
Output is correct |
19 |
Correct |
15 ms |
1996 KB |
Output is correct |
20 |
Correct |
11 ms |
2000 KB |
Output is correct |
21 |
Correct |
55 ms |
6908 KB |
Output is correct |
22 |
Correct |
65 ms |
6840 KB |
Output is correct |
23 |
Correct |
64 ms |
6944 KB |
Output is correct |
24 |
Correct |
69 ms |
7008 KB |
Output is correct |
25 |
Correct |
52 ms |
6844 KB |
Output is correct |
26 |
Correct |
57 ms |
6884 KB |
Output is correct |
27 |
Correct |
61 ms |
6924 KB |
Output is correct |
28 |
Correct |
66 ms |
6932 KB |
Output is correct |
29 |
Correct |
56 ms |
6944 KB |
Output is correct |
30 |
Correct |
55 ms |
6860 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 |
1 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 |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
512 KB |
Output is correct |
17 |
Correct |
12 ms |
512 KB |
Output is correct |
18 |
Correct |
14 ms |
424 KB |
Output is correct |
19 |
Correct |
13 ms |
464 KB |
Output is correct |
20 |
Correct |
8 ms |
516 KB |
Output is correct |
21 |
Correct |
58 ms |
972 KB |
Output is correct |
22 |
Correct |
46 ms |
1124 KB |
Output is correct |
23 |
Correct |
55 ms |
1080 KB |
Output is correct |
24 |
Correct |
57 ms |
1084 KB |
Output is correct |
25 |
Correct |
48 ms |
964 KB |
Output is correct |
26 |
Correct |
52 ms |
1084 KB |
Output is correct |
27 |
Correct |
47 ms |
1036 KB |
Output is correct |
28 |
Correct |
48 ms |
1020 KB |
Output is correct |
29 |
Correct |
50 ms |
1064 KB |
Output is correct |
30 |
Correct |
29 ms |
1044 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |