QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620763 | #4629. Longest Increasing Subsequence | huaxiamengjin | WA | 0ms | 52948kb | C++14 | 869b | 2024-10-07 21:05:14 | 2024-10-07 21:05:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a[100100];
int ans;
int c[100100][61];
int f[100100][61];
signed main(){
cin>>n;
for (int i=1;i<=n;i++)
cin>>a[i];
ans=n;
for (int i=1;i<n;i++){
int x=a[i+1]-a[i]-1;
for (int j=0;j<=60;j++)
if(x>(1ll<<j))c[i][j]=1ll<<j,x-=1ll<<j;
else{
c[i][j]=x;
break;
}
}
memset(f,-63,sizeof(f));
f[0][0]=1;
for (int i=1;i<n;i++){
for (int j=0;j<=60;j++){
if(c[i][j]==0)break;
f[i][j]=f[i-1][j];
if(c[i][j]!=(1ll<<j)){
f[i][j]=max(f[i][j],f[i-1][j]+c[i][j]);
int tmp=max(1ll<<j-1,c[i][j])+1;
for (int k=0;k<j;k++)
f[i][j]=max(f[i][j],f[i-1][k]+tmp);
}else{
for (int k=0;k<=j;k++)
f[i][j]=max(f[i][j],f[i-1][k]+c[i][j]);
}
}
}
for (int j=0;j<=60;j++)
ans=max(ans,f[n-1][j]);
cout<<ans<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 52948kb
input:
7 7 41 53 58 75 78 81
output:
11
result:
wrong answer 1st lines differ - expected: '22', found: '11'