# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
956215 |
2024-04-01T10:31:14 Z |
peteza |
Gap (APIO16_gap) |
C++14 |
|
55 ms |
3928 KB |
#include "gap.h"
#include <iostream>
#include <vector>
#include <utility>
using ll = long long;
const ll inf = 2e18;
long long findGap(int T, int N) {
if(T==1) {
ll cmin=0, cmax=inf, l=0, r=0;
std::vector<ll> v1, v2;
while(cmin <= cmax && v1.size() + v2.size() < N) {
MinMax(cmin, cmax, &l, &r);
if(l == -1) break;
v1.push_back(l); if(l != r) v2.push_back(r);
cmin = l+1; cmax = r-1;
}
ll amax = v2.back() - v1.back();
for(int i=0;i<v1.size()-1;i++) amax = std::max(amax, v1[i+1] - v1[i]);
for(int i=0;i<v2.size()-1;i++) amax = std::max(amax, v2[i] - v2[i+1]);
return amax;
} else {
ll rmin, rmax, l, r;
MinMax(0, inf, &rmin, &rmax);
ll amax = 1, i=1;
while(rmin < rmax) {
for(;i<=inf;i<<=1) {
MinMax(rmin+1, rmin+i, &l, &r);
if(l != -1) break;
}
if(i >= amax) i >>= 1;
i = std::max(i, 1ll);
amax = std::max(amax, l-rmin);
rmin = r;
}
return amax;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:12:47: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
12 | while(cmin <= cmax && v1.size() + v2.size() < N) {
| ~~~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i=0;i<v1.size()-1;i++) amax = std::max(amax, v1[i+1] - v1[i]);
| ~^~~~~~~~~~~~
gap.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for(int i=0;i<v2.size()-1;i++) amax = std::max(amax, v2[i] - v2[i+1]);
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2600 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2644 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
7 ms |
2888 KB |
Output is correct |
17 |
Correct |
7 ms |
2844 KB |
Output is correct |
18 |
Correct |
7 ms |
2848 KB |
Output is correct |
19 |
Correct |
7 ms |
2840 KB |
Output is correct |
20 |
Correct |
8 ms |
2812 KB |
Output is correct |
21 |
Correct |
29 ms |
3636 KB |
Output is correct |
22 |
Correct |
28 ms |
3660 KB |
Output is correct |
23 |
Correct |
28 ms |
3664 KB |
Output is correct |
24 |
Correct |
29 ms |
3696 KB |
Output is correct |
25 |
Correct |
25 ms |
3664 KB |
Output is correct |
26 |
Correct |
29 ms |
3928 KB |
Output is correct |
27 |
Correct |
28 ms |
3668 KB |
Output is correct |
28 |
Correct |
29 ms |
3664 KB |
Output is correct |
29 |
Correct |
28 ms |
3668 KB |
Output is correct |
30 |
Correct |
24 ms |
3660 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
2 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
3 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
5 |
Partially correct |
0 ms |
2392 KB |
Partially correct |
6 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Partially correct |
1 ms |
2644 KB |
Partially correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
16 |
Correct |
5 ms |
2580 KB |
Output is correct |
17 |
Correct |
6 ms |
2592 KB |
Output is correct |
18 |
Correct |
5 ms |
2592 KB |
Output is correct |
19 |
Correct |
5 ms |
2584 KB |
Output is correct |
20 |
Correct |
4 ms |
2564 KB |
Output is correct |
21 |
Correct |
20 ms |
2856 KB |
Output is correct |
22 |
Correct |
20 ms |
2856 KB |
Output is correct |
23 |
Correct |
23 ms |
3256 KB |
Output is correct |
24 |
Correct |
19 ms |
2860 KB |
Output is correct |
25 |
Partially correct |
55 ms |
2852 KB |
Partially correct |
26 |
Correct |
19 ms |
2856 KB |
Output is correct |
27 |
Correct |
20 ms |
2864 KB |
Output is correct |
28 |
Correct |
20 ms |
2764 KB |
Output is correct |
29 |
Correct |
20 ms |
2852 KB |
Output is correct |
30 |
Correct |
17 ms |
2848 KB |
Output is correct |
31 |
Partially correct |
1 ms |
2392 KB |
Partially correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |