QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#450321 | #4629. Longest Increasing Subsequence | Crysfly | WA | 0ms | 5696kb | C++14 | 1.3kb | 2024-06-22 09:32:25 | 2024-06-22 09:32:25 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 300005
#define inf 0x3f3f3f3f
int n,a[maxn];
int f[maxn][64];
int go[64];
signed main(){
n=read();
For(i,1,n)a[i]=read();
For(i,0,62) f[1][i]=1;
go[0]=1;
For(i,1,62) go[i]=(1ll<<(i-1));
For(i,2,n){
int t=a[i]-a[i-1];
int now=0;
For(j,0,62){
int w=go[j];
if(now+w<=t) now+=w;
else w=t-now,now+=w;
f[i][j]=f[i-1][j]+w;
}
For(j,1,62){
if((1ll<<j)>=t)break;
if((1ll<<j)<t && (1ll<<(j+1))>=t)
f[i][j]=max(f[i][j],f[i-1][j-1]+max(1ll<<(j-1),t-(1ll<<j))+((1ll<<(j+1))!=t));
}
For(j,1,62)f[i][j]=max(f[i][j],f[i][j-1]);
//For(j,0,5) cout<<f[i][j]<<" "; cout<<"\n";
}
cout<<f[n][62];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5696kb
input:
7 7 41 53 58 75 78 81
output:
21
result:
wrong answer 1st lines differ - expected: '22', found: '21'