# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
574224 |
2022-06-08T08:12:32 Z |
cadmiumsky |
Gap (APIO16_gap) |
C++14 |
|
59 ms |
3256 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
ll findGap(int t, int n) {
// cerr << t << ' ' << n << '\n';
ll l = 0, r = 1e18;
if(t == 1) {
vector<ll> elem;
n = (n + 1) / 2;
for(int i = 0; i < n; i++) {
MinMax(l, r, &l, &r);
elem.push_back(l);
elem.push_back(r);
l++;
r--;
}
sort(all(elem));
elem.resize(unique(all(elem)) - elem.begin());
ll mx = 0;
for(int i = 1; i < elem.size(); i++)
mx = max(mx, elem[i] - elem[i - 1]);
return mx;
}
MinMax(l, r, &l, &r);
ll mx = r;
vector<pii> v;
ll minl = (r - l + n - 2) / (n - 1);
v.emplace_back(l, l);
// cerr << l << ' ' << r << ' ' << minl << '\n';
for(ll i = l; i < mx; i += minl) {
// cerr << i << ' ' << i + minl << ' ' << mx << '\n';
MinMax(i, min(mx, i + minl) - 1, &l, &r);
if(l == -1)
continue;
v.emplace_back(l, r);
}
v.emplace_back(mx, mx);
mx = -1;
for(int i = 1; i < v.size(); i++)
mx = max(v[i].first - v[i - 1].second, mx);
return mx;
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i = 1; i < elem.size(); i++)
| ~~^~~~~~~~~~~~~
gap.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for(int i = 1; i < v.size(); i++)
| ~~^~~~~~~~~~
# |
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 |
13 ms |
808 KB |
Output is correct |
17 |
Correct |
11 ms |
896 KB |
Output is correct |
18 |
Correct |
12 ms |
848 KB |
Output is correct |
19 |
Correct |
10 ms |
856 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
40 ms |
2200 KB |
Output is correct |
22 |
Correct |
41 ms |
2216 KB |
Output is correct |
23 |
Correct |
45 ms |
2228 KB |
Output is correct |
24 |
Correct |
43 ms |
2328 KB |
Output is correct |
25 |
Correct |
43 ms |
2168 KB |
Output is correct |
26 |
Correct |
41 ms |
2200 KB |
Output is correct |
27 |
Correct |
42 ms |
2208 KB |
Output is correct |
28 |
Correct |
43 ms |
2152 KB |
Output is correct |
29 |
Correct |
45 ms |
2232 KB |
Output is correct |
30 |
Correct |
37 ms |
2176 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 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 |
460 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 |
12 ms |
848 KB |
Output is correct |
17 |
Correct |
14 ms |
856 KB |
Output is correct |
18 |
Correct |
13 ms |
848 KB |
Output is correct |
19 |
Correct |
12 ms |
848 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
54 ms |
2228 KB |
Output is correct |
22 |
Correct |
59 ms |
2204 KB |
Output is correct |
23 |
Correct |
51 ms |
2240 KB |
Output is correct |
24 |
Correct |
52 ms |
2192 KB |
Output is correct |
25 |
Correct |
51 ms |
3256 KB |
Output is correct |
26 |
Correct |
57 ms |
2240 KB |
Output is correct |
27 |
Correct |
54 ms |
2220 KB |
Output is correct |
28 |
Correct |
51 ms |
2196 KB |
Output is correct |
29 |
Correct |
52 ms |
2156 KB |
Output is correct |
30 |
Correct |
33 ms |
1444 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |