#include <bits/stdc++.h>
#ifndef SKY
#include "gap.h"
#endif // SKY
using namespace std;
#define ll long long
#define pb push_back
#define N 100010
#define ii pair<int,int>
#define fs first
#define sc second
#define ld double
int n;
#ifdef SKY
ll a[N],am=-1,mn,mx;
void MinMax(ll s,ll t, ll *u, ll *v)
{
if(s>t)
{
cout<<"NGU VC";
exit(0);
}
if(s>a[n]||a[lower_bound(a+1,a+1+n,s)-a]>t)
{
mn=-1;
mx=-1;
return;
}
mn=a[lower_bound(a+1,a+1+n,s)-a];
if(t>=a[n])
{
mx=a[n];
return;
}
mx=a[prev(upper_bound(a+1,a+1+n,t))-a];
}
#endif
long long findGap(int T, int cc)
{
n=cc;
ll L=0,R=1e18;
vector<ll>s;
int cnt=0;
while(L<=R)
{
cnt++;
if(cnt*2>(n+1))
break;
ll u,v;
MinMax(L,R,&u,&v);
#ifdef SKY
u=mn;v=mx;
#endif // SKY
//cout<<L<<" "<<R<<" "<<u<<" "<<v<<endl;
if(u==-1)
break;
s.pb(u);
s.pb(v);
L=u+1;
R=v-1;
}
sort(s.begin(),s.end());
s.erase(unique(s.begin(),s.end()),s.end());
ll res=0;
for(int i=0;i<s.size()-1;i++)
res=max(res,s[i+1]-s[i]);
return res;
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
int n,T;
cin>>T>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
cout<<findGap(T,n)<<endl;
return 0;
}
#endif // SKY
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:71:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(int i=0;i<s.size()-1;i++)
| ~^~~~~~~~~~~
gap.cpp:71:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
71 | for(int i=0;i<s.size()-1;i++)
| ^~~
gap.cpp:73:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
73 | return res;
| ^~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
11 ms |
848 KB |
Output is correct |
17 |
Correct |
11 ms |
932 KB |
Output is correct |
18 |
Correct |
11 ms |
848 KB |
Output is correct |
19 |
Correct |
9 ms |
876 KB |
Output is correct |
20 |
Correct |
7 ms |
848 KB |
Output is correct |
21 |
Correct |
37 ms |
2152 KB |
Output is correct |
22 |
Correct |
37 ms |
2208 KB |
Output is correct |
23 |
Correct |
39 ms |
2232 KB |
Output is correct |
24 |
Correct |
40 ms |
2152 KB |
Output is correct |
25 |
Correct |
38 ms |
2132 KB |
Output is correct |
26 |
Correct |
37 ms |
2244 KB |
Output is correct |
27 |
Correct |
38 ms |
2204 KB |
Output is correct |
28 |
Correct |
39 ms |
2180 KB |
Output is correct |
29 |
Correct |
39 ms |
2216 KB |
Output is correct |
30 |
Correct |
31 ms |
2208 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 |
Partially correct |
0 ms |
208 KB |
Partially correct |
3 |
Partially correct |
1 ms |
208 KB |
Partially correct |
4 |
Partially correct |
0 ms |
208 KB |
Partially correct |
5 |
Partially correct |
0 ms |
208 KB |
Partially correct |
6 |
Partially correct |
0 ms |
208 KB |
Partially correct |
7 |
Partially correct |
0 ms |
208 KB |
Partially correct |
8 |
Partially correct |
0 ms |
208 KB |
Partially correct |
9 |
Partially correct |
0 ms |
208 KB |
Partially correct |
10 |
Partially correct |
0 ms |
208 KB |
Partially correct |
11 |
Partially correct |
1 ms |
336 KB |
Partially correct |
12 |
Partially correct |
1 ms |
336 KB |
Partially correct |
13 |
Partially correct |
1 ms |
336 KB |
Partially correct |
14 |
Partially correct |
1 ms |
336 KB |
Partially correct |
15 |
Partially correct |
1 ms |
336 KB |
Partially correct |
16 |
Partially correct |
10 ms |
848 KB |
Partially correct |
17 |
Partially correct |
10 ms |
844 KB |
Partially correct |
18 |
Partially correct |
10 ms |
848 KB |
Partially correct |
19 |
Partially correct |
12 ms |
848 KB |
Partially correct |
20 |
Partially correct |
12 ms |
836 KB |
Partially correct |
21 |
Incorrect |
39 ms |
2240 KB |
Expected int32, but "2500100000" found |
22 |
Incorrect |
39 ms |
2160 KB |
Expected int32, but "2500100000" found |
23 |
Incorrect |
37 ms |
2240 KB |
Expected int32, but "2500100000" found |
24 |
Incorrect |
40 ms |
2184 KB |
Expected int32, but "2500100000" found |
25 |
Incorrect |
35 ms |
2220 KB |
Expected int32, but "2500100000" found |
26 |
Incorrect |
40 ms |
2248 KB |
Expected int32, but "2500100000" found |
27 |
Incorrect |
38 ms |
2208 KB |
Expected int32, but "2500100000" found |
28 |
Incorrect |
45 ms |
2176 KB |
Expected int32, but "2500100000" found |
29 |
Incorrect |
39 ms |
2204 KB |
Expected int32, but "2500100000" found |
30 |
Incorrect |
32 ms |
2240 KB |
Expected int32, but "2500100000" found |
31 |
Partially correct |
0 ms |
208 KB |
Partially correct |
32 |
Partially correct |
0 ms |
280 KB |
Partially correct |