#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define pb push_back
#define pii pair<long long, long long>
#define len(x) (long long)x.size()
template<typename A, typename B>
bool cmax(A &a, const B &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<typename A, typename B>
bool cmin(A &a, const B &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int askcount = 0;
pii ask(long long s, long long t) {
askcount++;
long long mn = 0, mx = 0;
MinMax(s, t, &mn, &mx);
return {mn, mx};
}
long long findGap(int T, int N) {
vector<long long> a(N);
long long itr1 = 0, itr2 = N - 1;
long long l = -1, r = (long long)1e18 + 1;
MinMax(l, r, &l, &r);
int dx = (r - l) / (N - 1);
int MAX = r;
r = l + dx;
while (l < MAX) {
pii res = ask(l, r);
if (res.F != -1) a.pb(res.F);
if (res.S != -1) a.pb(res.S);
l += dx;
r += dx;
}
long long best = -1;
sort(all(a));
// for (auto x: a) cout << x << "\n";
for (int i = 0; i < len(a) - 1; i++) {
cmax(best, a[i + 1] - a[i]);
}
return best;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:12: warning: unused variable 'itr1' [-Wunused-variable]
long long itr1 = 0, itr2 = N - 1;
^~~~
gap.cpp:43:22: warning: unused variable 'itr2' [-Wunused-variable]
long long itr1 = 0, itr2 = N - 1;
^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
11 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
16 |
Incorrect |
14 ms |
740 KB |
Output isn't correct |
17 |
Incorrect |
9 ms |
768 KB |
Output isn't correct |
18 |
Incorrect |
10 ms |
768 KB |
Output isn't correct |
19 |
Incorrect |
10 ms |
768 KB |
Output isn't correct |
20 |
Incorrect |
10 ms |
896 KB |
Output isn't correct |
21 |
Incorrect |
34 ms |
1932 KB |
Output isn't correct |
22 |
Incorrect |
33 ms |
1940 KB |
Output isn't correct |
23 |
Incorrect |
38 ms |
1880 KB |
Output isn't correct |
24 |
Incorrect |
30 ms |
2040 KB |
Output isn't correct |
25 |
Incorrect |
34 ms |
1836 KB |
Output isn't correct |
26 |
Incorrect |
32 ms |
1916 KB |
Output isn't correct |
27 |
Incorrect |
37 ms |
1912 KB |
Output isn't correct |
28 |
Incorrect |
27 ms |
1904 KB |
Output isn't correct |
29 |
Incorrect |
38 ms |
1912 KB |
Output isn't correct |
30 |
Incorrect |
42 ms |
2688 KB |
Output isn't correct |
31 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
10 |
Partially correct |
2 ms |
384 KB |
Partially correct |
11 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
13 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
16 |
Incorrect |
11 ms |
768 KB |
Output isn't correct |
17 |
Incorrect |
9 ms |
768 KB |
Output isn't correct |
18 |
Incorrect |
9 ms |
768 KB |
Output isn't correct |
19 |
Incorrect |
9 ms |
768 KB |
Output isn't correct |
20 |
Partially correct |
10 ms |
1024 KB |
Partially correct |
21 |
Incorrect |
29 ms |
1916 KB |
Output isn't correct |
22 |
Incorrect |
30 ms |
1920 KB |
Output isn't correct |
23 |
Incorrect |
32 ms |
1912 KB |
Output isn't correct |
24 |
Incorrect |
33 ms |
1912 KB |
Output isn't correct |
25 |
Incorrect |
21 ms |
1920 KB |
Output isn't correct |
26 |
Incorrect |
43 ms |
1912 KB |
Output isn't correct |
27 |
Incorrect |
29 ms |
1912 KB |
Output isn't correct |
28 |
Incorrect |
27 ms |
1912 KB |
Output isn't correct |
29 |
Incorrect |
47 ms |
1956 KB |
Output isn't correct |
30 |
Partially correct |
41 ms |
2688 KB |
Partially correct |
31 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
32 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |