QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620665 | #4629. Longest Increasing Subsequence | huaxiamengjin | WA | 0ms | 54624kb | C++14 | 821b | 2024-10-07 20:11:01 | 2024-10-07 20:11:01 |
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+1;break;}
// for (int j=0;j<=5;j++)
// cout<<i<<" "<<j<<" "<<c[i][j]<<"\n";
// cout<<"*****\n";
}
memset(f,-63,sizeof(f));
for (int i=1;i<n;i++){
for (int j=0;j<=60;j++){
f[i][j]=max(i+c[i][j],f[i-1][j]);
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<=5;j++)
// cout<<i<<" "<<j<<" "<<f[i][j]<<"\n";
// cout<<"&&&&&\n";
}
for (int j=0;j<=60;j++)
ans=max(ans,f[n-1][j]);
cout<<ans<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 53976kb
input:
7 7 41 53 58 75 78 81
output:
22
result:
ok single line: '22'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 54624kb
input:
8 174 223 259 368 618 738 893 1810
output:
670
result:
wrong answer 1st lines differ - expected: '671', found: '670'