#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#include "gap.h"
//#define int long long
template <class F, class _S>
bool chmin(F &u, const _S &v){
bool flag = false;
if ( u > v ){
u = v; flag |= true;
}
return flag;
}
template <class F, class _S>
bool chmax(F &u, const _S &v){
bool flag = false;
if ( u < v ){
u = v; flag |= true;
}
return flag;
}
int solve1(int t, int n){
long long l = 0, r = 1e18;
vector<int> a, b;
long long lf = 1, rf = 1;
while(1){
MinMax(l, r, &lf, &rf);
if(lf == -1)break;
a.pb(lf);
b.pb(rf);
l = lf+1, r = rf-1;
if(lf == rf || a.size()*2 >= n)break;
}
int ans = 1;
reverse(all(b));
for(int i = 1; i < (int)a.size(); i++)
chmax(ans, a[i] - a[i-1]);
for(int i = 1; i < (int)b.size(); i++)
chmax(ans, b[i] - b[i-1]);
return ans;
}
long long findGap(int t, int n)
{
//if(t == 1){
return solve1(t, n);
//}
return 0;
}
Compilation message
gap.cpp: In function 'int solve1(int, int)':
gap.cpp:42:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if(lf == rf || a.size()*2 >= n)break;
| ~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Incorrect |
7 ms |
600 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
600 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
600 KB |
Output isn't correct |
19 |
Incorrect |
6 ms |
600 KB |
Output isn't correct |
20 |
Correct |
5 ms |
600 KB |
Output is correct |
21 |
Incorrect |
25 ms |
1732 KB |
Output isn't correct |
22 |
Incorrect |
25 ms |
1668 KB |
Output isn't correct |
23 |
Incorrect |
33 ms |
1656 KB |
Output isn't correct |
24 |
Incorrect |
26 ms |
1668 KB |
Output isn't correct |
25 |
Correct |
23 ms |
1668 KB |
Output is correct |
26 |
Incorrect |
25 ms |
1668 KB |
Output isn't correct |
27 |
Incorrect |
28 ms |
1664 KB |
Output isn't correct |
28 |
Incorrect |
25 ms |
1668 KB |
Output isn't correct |
29 |
Incorrect |
25 ms |
1668 KB |
Output isn't correct |
30 |
Correct |
21 ms |
1732 KB |
Output is correct |
31 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Partially correct |
1 ms |
344 KB |
Partially correct |
6 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Partially correct |
0 ms |
344 KB |
Partially correct |
11 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
15 |
Partially correct |
0 ms |
344 KB |
Partially correct |
16 |
Incorrect |
6 ms |
816 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
600 KB |
Output isn't correct |
18 |
Incorrect |
8 ms |
852 KB |
Output isn't correct |
19 |
Incorrect |
6 ms |
688 KB |
Output isn't correct |
20 |
Partially correct |
5 ms |
600 KB |
Partially correct |
21 |
Incorrect |
32 ms |
1668 KB |
Expected int32, but "2500100000" found |
22 |
Incorrect |
26 ms |
1668 KB |
Expected int32, but "2500100000" found |
23 |
Incorrect |
27 ms |
1660 KB |
Expected int32, but "2500100000" found |
24 |
Incorrect |
27 ms |
1660 KB |
Expected int32, but "2500100000" found |
25 |
Incorrect |
31 ms |
1668 KB |
Expected int32, but "2500100000" found |
26 |
Incorrect |
25 ms |
1668 KB |
Expected int32, but "2500100000" found |
27 |
Incorrect |
25 ms |
1760 KB |
Expected int32, but "2500100000" found |
28 |
Incorrect |
27 ms |
1660 KB |
Expected int32, but "2500100000" found |
29 |
Incorrect |
27 ms |
1672 KB |
Expected int32, but "2500100000" found |
30 |
Incorrect |
21 ms |
1672 KB |
Expected int32, but "2500100000" found |
31 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |