# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1113722 |
2024-11-17T08:48:17 Z |
simona1230 |
Gap (APIO16_gap) |
C++17 |
|
45 ms |
5920 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
/*int nn;
long long a[200001];
void MinMax(long long l,long long r,long long *mn,long long *mx)
{
*mn=-1;
for(int i=1;i<=nn;i++)
if(a[i]>=l)
{
*mn=a[i];
break;
}
*mx=-1;
for(int i=nn;i>=1;i--)
if(a[i]<=r)
{
*mx=a[i];
break;
}
}*/
long long n;
vector<long long> v;
long long solve(long long l,long long r)
{
if(l>r)return 0;
//cout<<l<<" "<<r<<" "<<ll<<" "<<rr<<endl;
long long ans=0;
long long len=r-l+1;
long long b=max(1LL*1,len/n);
for(long long i=l;i<=r;i+=b)
{
long long j=min(i+b-1,r);
long long mn=0,mx=0;
MinMax(i,j,&mn,&mx);
if(mn==-1)continue;
v.push_back(mn);
v.push_back(mx);
solve(mn+1,mx-1);
}
}
long long findGap(int t,int N)
{
n=N;
solve(0,1e18);
long long ans=0;
sort(v.begin(),v.end());
for(int i=1;i<v.size();i++)
ans=max(ans,v[i]-v[i-1]);
return ans;
}
/*int main()
{
long long d=0;
int x;
cin>>x>>nn;
for(int i=1;i<=nn;i++)
{
cin>>a[i];
if(i!=1)d=max(d,a[i]-a[i-1]);
}
long long answer=findGap(1,nn);
cout<<d<<" "<<answer<<endl;
}*/
Compilation message
gap.cpp: In function 'long long int solve(long long int, long long int)':
gap.cpp:34:15: warning: unused variable 'ans' [-Wunused-variable]
34 | long long ans=0;
| ^~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i=1;i<v.size();i++)
| ~^~~~~~~~~
gap.cpp: In function 'long long int solve(long long int, long long int)':
gap.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
6 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
10 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
11 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
2 ms |
2384 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
10 ms |
2384 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
10 ms |
2384 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
7 ms |
2384 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
7 ms |
2384 KB |
Execution failed because the return code was nonzero |
20 |
Runtime error |
3 ms |
2384 KB |
Execution failed because the return code was nonzero |
21 |
Runtime error |
26 ms |
2872 KB |
Execution failed because the return code was nonzero |
22 |
Runtime error |
26 ms |
2640 KB |
Execution failed because the return code was nonzero |
23 |
Runtime error |
27 ms |
2640 KB |
Execution failed because the return code was nonzero |
24 |
Runtime error |
30 ms |
2744 KB |
Execution failed because the return code was nonzero |
25 |
Runtime error |
45 ms |
5920 KB |
Execution failed because the return code was nonzero |
26 |
Runtime error |
27 ms |
2640 KB |
Execution failed because the return code was nonzero |
27 |
Runtime error |
26 ms |
2640 KB |
Execution failed because the return code was nonzero |
28 |
Runtime error |
30 ms |
2640 KB |
Execution failed because the return code was nonzero |
29 |
Runtime error |
26 ms |
2640 KB |
Execution failed because the return code was nonzero |
30 |
Runtime error |
9 ms |
2640 KB |
Execution failed because the return code was nonzero |
31 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
32 |
Runtime error |
1 ms |
2420 KB |
Execution failed because the return code was nonzero |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
2392 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
6 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
7 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
8 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
9 |
Runtime error |
1 ms |
2552 KB |
Execution failed because the return code was nonzero |
10 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
11 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
12 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
2 ms |
2384 KB |
Execution failed because the return code was nonzero |
14 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
8 ms |
2384 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
7 ms |
2384 KB |
Execution failed because the return code was nonzero |
18 |
Runtime error |
7 ms |
2488 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
7 ms |
2384 KB |
Execution failed because the return code was nonzero |
20 |
Runtime error |
4 ms |
2384 KB |
Execution failed because the return code was nonzero |
21 |
Runtime error |
25 ms |
2732 KB |
Execution failed because the return code was nonzero |
22 |
Runtime error |
26 ms |
2640 KB |
Execution failed because the return code was nonzero |
23 |
Runtime error |
27 ms |
2640 KB |
Execution failed because the return code was nonzero |
24 |
Runtime error |
26 ms |
2640 KB |
Execution failed because the return code was nonzero |
25 |
Runtime error |
37 ms |
5820 KB |
Execution failed because the return code was nonzero |
26 |
Runtime error |
40 ms |
2640 KB |
Execution failed because the return code was nonzero |
27 |
Runtime error |
25 ms |
2640 KB |
Execution failed because the return code was nonzero |
28 |
Runtime error |
26 ms |
2640 KB |
Execution failed because the return code was nonzero |
29 |
Runtime error |
25 ms |
2640 KB |
Execution failed because the return code was nonzero |
30 |
Runtime error |
10 ms |
2856 KB |
Execution failed because the return code was nonzero |
31 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
32 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |