QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620595 | #4629. Longest Increasing Subsequence | huaxiamengjin | WA | 1ms | 5684kb | C++14 | 673b | 2024-10-07 19:33:30 | 2024-10-07 19:33:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a[100100];
int ans;
int c[100100][31];
int f[100100][31];
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<=30;j++)
if(x>(1ll<<j))c[i][j]=1ll<<j,x-=1ll<<j;
else {c[i][j]=x;break;}
// for (int j=0;j<=4;j++)
// cout<<i<<" "<<j<<" "<<c[i][j]<<"\n";
}
for (int i=1;i<n;i++){
for (int j=0;j<=30;j++){
f[i][j]=i-1+c[i][j]+1;
for (int k=0;k<=j;k++)
f[i][j]=max(f[i][j],f[i-1][k]+c[i][j]+(j>k));
}
}
for (int j=0;j<=30;j++)
ans=max(ans,f[n-1][j]);
cout<<ans<<"\n";
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5684kb
input:
7 7 41 53 58 75 78 81
output:
23
result:
wrong answer 1st lines differ - expected: '22', found: '23'