#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
long long findGap(int T, int N)
{
ll l, r, ans = 0, n = N;
MinMax(0, 1e18, &l, &r);
if(T==1){
for(int i = 0; i < (n-1)/2; i++){
ll nxtl, nxtr;
MinMax(l+1, r-1, &nxtl, &nxtr);
ans = max(ans, nxtl-l);
ans = max(ans, r-nxtr);
l = nxtl;
r = nxtr;
}
ans = max(ans, r-l);
}
else{
vector<pair<ll, ll>> vec;
ll dist = (r-l-1)/n + !!((r-l-1)%n);
for(ll i = l+1; i < r; i+=dist){
ll rb = min(r-1, i+dist-1);
pair<ll, ll> tmp;
MinMax(i, rb, &tmp.f, &tmp.s);
if(tmp.f >= 0)vec.push_back(tmp);
}
if(vec.empty())ans = r-l;
else{
ans = max(vec[0].f - l, r-vec.back().s);
for(int i = 1; i < vec.size(); i++){
ans = max(ans, vec[i].f - vec[i-1].s);
}
}
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:30: 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]
38 | for(int i = 1; i < vec.size(); i++){
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
512 KB |
Output is correct |
17 |
Correct |
9 ms |
464 KB |
Output is correct |
18 |
Correct |
8 ms |
504 KB |
Output is correct |
19 |
Correct |
9 ms |
520 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
34 ms |
1088 KB |
Output is correct |
22 |
Correct |
38 ms |
1048 KB |
Output is correct |
23 |
Correct |
36 ms |
1164 KB |
Output is correct |
24 |
Correct |
33 ms |
1084 KB |
Output is correct |
25 |
Correct |
30 ms |
1064 KB |
Output is correct |
26 |
Correct |
34 ms |
1084 KB |
Output is correct |
27 |
Correct |
34 ms |
1076 KB |
Output is correct |
28 |
Correct |
35 ms |
968 KB |
Output is correct |
29 |
Correct |
35 ms |
1008 KB |
Output is correct |
30 |
Correct |
27 ms |
1100 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
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 |
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 |
12 ms |
848 KB |
Output is correct |
17 |
Correct |
15 ms |
848 KB |
Output is correct |
18 |
Correct |
12 ms |
808 KB |
Output is correct |
19 |
Correct |
12 ms |
908 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
49 ms |
2216 KB |
Output is correct |
22 |
Correct |
48 ms |
2164 KB |
Output is correct |
23 |
Correct |
47 ms |
2240 KB |
Output is correct |
24 |
Correct |
49 ms |
2220 KB |
Output is correct |
25 |
Correct |
46 ms |
3204 KB |
Output is correct |
26 |
Correct |
47 ms |
2204 KB |
Output is correct |
27 |
Correct |
47 ms |
2204 KB |
Output is correct |
28 |
Correct |
56 ms |
2248 KB |
Output is correct |
29 |
Correct |
55 ms |
2188 KB |
Output is correct |
30 |
Correct |
25 ms |
1476 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |