# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
796428 |
2023-07-28T11:32:52 Z |
TheSahib |
Gap (APIO16_gap) |
C++14 |
|
42 ms |
2228 KB |
#include "gap.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const ll MAX = 1000000000000000000ll;
ll findGap(int T, int N)
{
if(T == 1){
ll l = 0, r = MAX;
vector<ll> v;
while(l <= r && v.size() < N){
ll mn, mx;
MinMax(l, r, &mn, &mx);
v.push_back(mn);
v.push_back(mx);
l = mn + 1;
r = mx - 1;
}
sort(v.begin(), v.end());
ll ans = 1;
for (int i = 1; i < v.size(); i++)
{
ans = max(ans, v[i] - v[i - 1]);
}
return ans;
}
ll mn, mx;
MinMax(0, MAX, &mn, &mx);
ll ans = (mx - mn + 1) / N;
ll p = mn;
while(p < mx){
if(p + ans >= mx) break;
ll l = 0, h = 0;
ll dist = ans + 1;
while(true){
MinMax(p + 1, p + dist, &l, &h);
if(l == -1){
dist *= 2;
continue;
}
ans = max(ans, l - p);
p = h;
break;
}
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:16:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
16 | while(l <= r && v.size() < N){
| ~~~~~~~~~^~~
gap.cpp:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | 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 |
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 |
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 |
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 |
8 ms |
912 KB |
Output is correct |
17 |
Correct |
11 ms |
848 KB |
Output is correct |
18 |
Correct |
8 ms |
888 KB |
Output is correct |
19 |
Correct |
9 ms |
900 KB |
Output is correct |
20 |
Correct |
7 ms |
848 KB |
Output is correct |
21 |
Correct |
31 ms |
2200 KB |
Output is correct |
22 |
Correct |
33 ms |
2136 KB |
Output is correct |
23 |
Correct |
42 ms |
2168 KB |
Output is correct |
24 |
Correct |
31 ms |
2140 KB |
Output is correct |
25 |
Correct |
28 ms |
2208 KB |
Output is correct |
26 |
Correct |
31 ms |
2212 KB |
Output is correct |
27 |
Correct |
31 ms |
2196 KB |
Output is correct |
28 |
Correct |
37 ms |
2192 KB |
Output is correct |
29 |
Correct |
31 ms |
2208 KB |
Output is correct |
30 |
Correct |
27 ms |
2228 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 |
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 |
1 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 |
1 ms |
256 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 |
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 |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
464 KB |
Output is correct |
17 |
Correct |
5 ms |
464 KB |
Output is correct |
18 |
Correct |
5 ms |
464 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
4 ms |
464 KB |
Output is correct |
21 |
Correct |
18 ms |
1088 KB |
Output is correct |
22 |
Correct |
17 ms |
1104 KB |
Output is correct |
23 |
Correct |
17 ms |
1020 KB |
Output is correct |
24 |
Correct |
18 ms |
1064 KB |
Output is correct |
25 |
Correct |
37 ms |
1056 KB |
Output is correct |
26 |
Correct |
18 ms |
1072 KB |
Output is correct |
27 |
Correct |
23 ms |
1032 KB |
Output is correct |
28 |
Correct |
18 ms |
1064 KB |
Output is correct |
29 |
Correct |
22 ms |
1056 KB |
Output is correct |
30 |
Correct |
9 ms |
1084 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |