#include "gap.h"
#include <bits/stdc++.h>
#define ff(i,a,b) for(int i = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int i = (a); (i) >= (b); --(i))
#define pb push_back
#define ll long long
using namespace std;
ll findGap(int t, int n){
if(t == 1){
vector<ll> niz;
ll l,r;
MinMax(0, 1e18, &l, &r);
niz.pb(l);
niz.pb(r);
ff(i,1,(n-1)/2){
MinMax(l + 1, r - 1, &l, &r);
if(l != -1)niz.pb(l);
if(r != -1 && l != r)niz.pb(r);
}
sort(niz.begin(), niz.end());
ll ans = 0;
ff(i,0,n-1)ans = max(ans, niz[i + 1] - niz[i]);
return ans;
}
else{
vector<ll> niz;
ll l,r;
MinMax(0, 1e18, &l, &r);
if(n == 2)return r - l;
niz.pb(l);
niz.pb(r);
ll d = (r - l + n - 3) / (n - 2);
for(ll i = l + 1; i < r; i += d){
ll x,y;
MinMax(i, i + d - 1, &x, &y);
if(x != -1)niz.pb(x);
if(y != -1 && x != y)niz.pb(y);
}
sort(niz.begin(), niz.end());
niz.erase(unique(niz.begin(), niz.end()), niz.end());
ll ans = 0;
ff(i,0,niz.size()-1)ans = max(ans, niz[i + 1] - niz[i]);
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:3:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
3 | #define ff(i,a,b) for(int i = (a); (i) <= (b); ++(i))
| ~~~~^~~~~~
gap.cpp:44:3: note: in expansion of macro 'ff'
44 | ff(i,0,niz.size()-1)ans = max(ans, niz[i + 1] - niz[i]);
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
2 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
11 ms |
840 KB |
Output is correct |
17 |
Correct |
10 ms |
840 KB |
Output is correct |
18 |
Correct |
11 ms |
896 KB |
Output is correct |
19 |
Correct |
12 ms |
868 KB |
Output is correct |
20 |
Correct |
9 ms |
888 KB |
Output is correct |
21 |
Correct |
41 ms |
2168 KB |
Output is correct |
22 |
Correct |
38 ms |
2184 KB |
Output is correct |
23 |
Correct |
47 ms |
2148 KB |
Output is correct |
24 |
Correct |
38 ms |
2208 KB |
Output is correct |
25 |
Correct |
35 ms |
2228 KB |
Output is correct |
26 |
Correct |
45 ms |
2192 KB |
Output is correct |
27 |
Correct |
40 ms |
2196 KB |
Output is correct |
28 |
Correct |
43 ms |
2192 KB |
Output is correct |
29 |
Correct |
45 ms |
2192 KB |
Output is correct |
30 |
Correct |
35 ms |
2240 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
284 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
14 ms |
808 KB |
Output is correct |
17 |
Correct |
12 ms |
840 KB |
Output is correct |
18 |
Correct |
13 ms |
860 KB |
Output is correct |
19 |
Correct |
12 ms |
800 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
57 ms |
2200 KB |
Output is correct |
22 |
Correct |
51 ms |
2196 KB |
Output is correct |
23 |
Correct |
51 ms |
2232 KB |
Output is correct |
24 |
Correct |
50 ms |
2192 KB |
Output is correct |
25 |
Correct |
47 ms |
2232 KB |
Output is correct |
26 |
Correct |
53 ms |
2232 KB |
Output is correct |
27 |
Correct |
56 ms |
2184 KB |
Output is correct |
28 |
Correct |
54 ms |
2352 KB |
Output is correct |
29 |
Correct |
50 ms |
2196 KB |
Output is correct |
30 |
Correct |
26 ms |
1476 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |