#include <bits/stdc++.h>
#include "gap.h"
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))
using namespace std;
const ll LINF = 1e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, m, a[mxN], b[2][mxN];
ll findGap(int T, int N){
vector<ll> a;
ll L = 0, R = LINF, l, r;
if (T == 1){
while (a.size() < N){
MinMax(L, R, &l, &r);
a.pb(l); a.pb(r);
L = l+1; R = r-1;
}
}
else{
MinMax(0, LINF, &L, &R);
a.pb(L); a.pb(R);
L++; R--;
ll d = (R-L+N-1) / (N-1);
r = L-1;
while (r < R){
l = r+1; r = l+d-1;
if (R-r < d) r = R;
ll mn, mx;
MinMax(l, r, &mn, &mx);
if (~mn){
a.pb(mn); a.pb(mx);
}
}
}
sort(all(a));
ll d = a[1] - a[0];
for (int i = 2; i < a.size(); i++)
smax(d, a[i] - a[i-1]);
return d;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | while (a.size() < N){
| ~~~~~~~~~^~~
gap.cpp:66:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for (int i = 2; i < a.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 |
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 |
11 ms |
900 KB |
Output is correct |
17 |
Correct |
10 ms |
848 KB |
Output is correct |
18 |
Correct |
11 ms |
808 KB |
Output is correct |
19 |
Correct |
13 ms |
900 KB |
Output is correct |
20 |
Correct |
8 ms |
812 KB |
Output is correct |
21 |
Correct |
41 ms |
2168 KB |
Output is correct |
22 |
Correct |
42 ms |
2204 KB |
Output is correct |
23 |
Correct |
40 ms |
2204 KB |
Output is correct |
24 |
Correct |
47 ms |
2200 KB |
Output is correct |
25 |
Correct |
36 ms |
2236 KB |
Output is correct |
26 |
Correct |
42 ms |
2192 KB |
Output is correct |
27 |
Correct |
39 ms |
2176 KB |
Output is correct |
28 |
Correct |
40 ms |
2204 KB |
Output is correct |
29 |
Correct |
40 ms |
2224 KB |
Output is correct |
30 |
Correct |
34 ms |
2172 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 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 |
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 |
12 ms |
848 KB |
Output is correct |
17 |
Correct |
13 ms |
848 KB |
Output is correct |
18 |
Correct |
14 ms |
892 KB |
Output is correct |
19 |
Correct |
15 ms |
832 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
54 ms |
2368 KB |
Output is correct |
22 |
Correct |
53 ms |
2256 KB |
Output is correct |
23 |
Correct |
58 ms |
2192 KB |
Output is correct |
24 |
Correct |
51 ms |
2216 KB |
Output is correct |
25 |
Correct |
53 ms |
3216 KB |
Output is correct |
26 |
Correct |
54 ms |
2240 KB |
Output is correct |
27 |
Correct |
54 ms |
2240 KB |
Output is correct |
28 |
Correct |
53 ms |
2208 KB |
Output is correct |
29 |
Correct |
57 ms |
2164 KB |
Output is correct |
30 |
Correct |
27 ms |
1504 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |