# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1113714 |
2024-11-17T08:31:49 Z |
simona1230 |
Gap (APIO16_gap) |
C++17 |
|
2000 ms |
2804 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;
long long solve(long long l,long long r,long long ll,long long rr)
{
if(l==-1||l>r)return 0;
//cout<<l<<" "<<r<<" "<<ll<<" "<<rr<<endl;
long long ans=0;
long long len=r-l+1;
long long s=sqrt(len);
long long b=len/n;
long long last=-1;
for(long long i=l;i<=r;i+=b)
{
long long j=min(i+b-1,r);
long long mn=0,mx=0;
//cout<<i<<" "<<j<<endl;
MinMax(i,j,&mn,&mx);
if(mn==-1)continue;
if(last!=-1)ans=max(ans,mn-last);
else if(ll!=-1)ans=max(ans,mn-ll);
last=mx;
ans=max(ans,solve(mn+1,mx-1,mn,mx));
}
if(last==-1)last=ll;
if(last!=-1&&rr!=-1)ans=max(ans,rr-last);
return ans;
}
long long findGap(int t,int N)
{
n=N;
return solve(1,1e18,-1,-1);
}
/*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, long long int, long long int)':
gap.cpp:34:15: warning: unused variable 's' [-Wunused-variable]
34 | long long s=sqrt(len);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
10 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
11 |
Incorrect |
48 ms |
2496 KB |
Output isn't correct |
12 |
Incorrect |
39 ms |
2384 KB |
Output isn't correct |
13 |
Incorrect |
40 ms |
2384 KB |
Output isn't correct |
14 |
Incorrect |
39 ms |
2384 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
16 |
Execution timed out |
3076 ms |
2540 KB |
Time limit exceeded |
17 |
Execution timed out |
3069 ms |
2384 KB |
Time limit exceeded |
18 |
Execution timed out |
3065 ms |
2384 KB |
Time limit exceeded |
19 |
Execution timed out |
3052 ms |
2384 KB |
Time limit exceeded |
20 |
Runtime error |
4 ms |
2384 KB |
Execution failed because the return code was nonzero |
21 |
Execution timed out |
3079 ms |
2608 KB |
Time limit exceeded |
22 |
Execution timed out |
3057 ms |
2640 KB |
Time limit exceeded |
23 |
Execution timed out |
3054 ms |
2640 KB |
Time limit exceeded |
24 |
Execution timed out |
3067 ms |
2640 KB |
Time limit exceeded |
25 |
Incorrect |
46 ms |
2640 KB |
Output isn't correct |
26 |
Execution timed out |
3068 ms |
2640 KB |
Time limit exceeded |
27 |
Execution timed out |
3064 ms |
2640 KB |
Time limit exceeded |
28 |
Execution timed out |
3056 ms |
2640 KB |
Time limit exceeded |
29 |
Execution timed out |
3058 ms |
2612 KB |
Time limit exceeded |
30 |
Runtime error |
8 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 |
2416 KB |
Execution failed because the return code was nonzero |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
3 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
4 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
5 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
6 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
7 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
8 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
9 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
10 |
Runtime error |
1 ms |
2384 KB |
Execution failed because the return code was nonzero |
11 |
Partially correct |
39 ms |
2384 KB |
Partially correct |
12 |
Partially correct |
39 ms |
2384 KB |
Partially correct |
13 |
Partially correct |
43 ms |
2384 KB |
Partially correct |
14 |
Partially correct |
41 ms |
2384 KB |
Partially correct |
15 |
Partially correct |
1 ms |
2384 KB |
Partially correct |
16 |
Execution timed out |
3081 ms |
2540 KB |
Time limit exceeded |
17 |
Execution timed out |
3064 ms |
2384 KB |
Time limit exceeded |
18 |
Execution timed out |
3047 ms |
2384 KB |
Time limit exceeded |
19 |
Execution timed out |
3057 ms |
2384 KB |
Time limit exceeded |
20 |
Runtime error |
4 ms |
2384 KB |
Execution failed because the return code was nonzero |
21 |
Execution timed out |
3077 ms |
2804 KB |
Time limit exceeded |
22 |
Execution timed out |
3053 ms |
2640 KB |
Time limit exceeded |
23 |
Execution timed out |
3047 ms |
2804 KB |
Time limit exceeded |
24 |
Execution timed out |
3062 ms |
2640 KB |
Time limit exceeded |
25 |
Partially correct |
47 ms |
2640 KB |
Partially correct |
26 |
Execution timed out |
3055 ms |
2640 KB |
Time limit exceeded |
27 |
Execution timed out |
3063 ms |
2640 KB |
Time limit exceeded |
28 |
Execution timed out |
3054 ms |
2640 KB |
Time limit exceeded |
29 |
Execution timed out |
3063 ms |
2640 KB |
Time limit exceeded |
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 |
2384 KB |
Execution failed because the return code was nonzero |