#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)
{
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 b=len/n;
if(len%n)b++;
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);
last=mx;
ans=max(ans,solve(mn,mx));
}
return ans;
}
long long findGap(int t,int N)
{
n=N;
return solve(1,1e18);
}
/*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;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
519 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Runtime error |
555 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Runtime error |
609 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Runtime error |
554 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Runtime error |
536 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Runtime error |
638 ms |
524288 KB |
Execution killed with signal 9 |
7 |
Runtime error |
650 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Runtime error |
657 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Runtime error |
648 ms |
524288 KB |
Execution killed with signal 9 |
10 |
Runtime error |
631 ms |
524288 KB |
Execution killed with signal 9 |
11 |
Runtime error |
719 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Runtime error |
758 ms |
524288 KB |
Execution killed with signal 9 |
13 |
Runtime error |
747 ms |
524288 KB |
Execution killed with signal 9 |
14 |
Runtime error |
754 ms |
524288 KB |
Execution killed with signal 9 |
15 |
Runtime error |
674 ms |
524288 KB |
Execution killed with signal 9 |
16 |
Runtime error |
840 ms |
524288 KB |
Execution killed with signal 9 |
17 |
Runtime error |
854 ms |
524288 KB |
Execution killed with signal 9 |
18 |
Runtime error |
897 ms |
524288 KB |
Execution killed with signal 9 |
19 |
Runtime error |
964 ms |
524288 KB |
Execution killed with signal 9 |
20 |
Runtime error |
965 ms |
524288 KB |
Execution killed with signal 9 |
21 |
Runtime error |
998 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Runtime error |
1012 ms |
524288 KB |
Execution killed with signal 9 |
23 |
Runtime error |
1064 ms |
524288 KB |
Execution killed with signal 9 |
24 |
Runtime error |
1016 ms |
524288 KB |
Execution killed with signal 9 |
25 |
Runtime error |
962 ms |
524288 KB |
Execution killed with signal 9 |
26 |
Runtime error |
938 ms |
524288 KB |
Execution killed with signal 9 |
27 |
Runtime error |
993 ms |
524288 KB |
Execution killed with signal 9 |
28 |
Runtime error |
1058 ms |
524288 KB |
Execution killed with signal 9 |
29 |
Runtime error |
1012 ms |
524288 KB |
Execution killed with signal 9 |
30 |
Runtime error |
1030 ms |
524288 KB |
Execution killed with signal 9 |
31 |
Runtime error |
626 ms |
524288 KB |
Execution killed with signal 9 |
32 |
Runtime error |
635 ms |
524288 KB |
Execution killed with signal 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
482 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Runtime error |
534 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Runtime error |
577 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Runtime error |
579 ms |
524288 KB |
Execution killed with signal 9 |
5 |
Runtime error |
584 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Runtime error |
619 ms |
524288 KB |
Execution killed with signal 9 |
7 |
Runtime error |
628 ms |
524288 KB |
Execution killed with signal 9 |
8 |
Runtime error |
624 ms |
524288 KB |
Execution killed with signal 9 |
9 |
Runtime error |
591 ms |
524288 KB |
Execution killed with signal 9 |
10 |
Runtime error |
583 ms |
524288 KB |
Execution killed with signal 9 |
11 |
Runtime error |
705 ms |
524288 KB |
Execution killed with signal 9 |
12 |
Runtime error |
774 ms |
524288 KB |
Execution killed with signal 9 |
13 |
Runtime error |
768 ms |
524288 KB |
Execution killed with signal 9 |
14 |
Runtime error |
736 ms |
524288 KB |
Execution killed with signal 9 |
15 |
Runtime error |
760 ms |
524288 KB |
Execution killed with signal 9 |
16 |
Runtime error |
930 ms |
524288 KB |
Execution killed with signal 9 |
17 |
Runtime error |
919 ms |
524288 KB |
Execution killed with signal 9 |
18 |
Runtime error |
892 ms |
524288 KB |
Execution killed with signal 9 |
19 |
Runtime error |
908 ms |
524288 KB |
Execution killed with signal 9 |
20 |
Runtime error |
915 ms |
524288 KB |
Execution killed with signal 9 |
21 |
Runtime error |
1020 ms |
524288 KB |
Execution killed with signal 9 |
22 |
Runtime error |
985 ms |
524288 KB |
Execution killed with signal 9 |
23 |
Runtime error |
955 ms |
524288 KB |
Execution killed with signal 9 |
24 |
Runtime error |
1020 ms |
524288 KB |
Execution killed with signal 9 |
25 |
Runtime error |
1060 ms |
524288 KB |
Execution killed with signal 9 |
26 |
Runtime error |
1072 ms |
524288 KB |
Execution killed with signal 9 |
27 |
Runtime error |
1016 ms |
524288 KB |
Execution killed with signal 9 |
28 |
Runtime error |
1020 ms |
524288 KB |
Execution killed with signal 9 |
29 |
Runtime error |
1037 ms |
524288 KB |
Execution killed with signal 9 |
30 |
Runtime error |
1026 ms |
524288 KB |
Execution killed with signal 9 |
31 |
Runtime error |
646 ms |
524288 KB |
Execution killed with signal 9 |
32 |
Runtime error |
635 ms |
524288 KB |
Execution killed with signal 9 |