QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#503531 | #4629. Longest Increasing Subsequence | tarjen# | WA | 0ms | 3528kb | C++20 | 1.1kb | 2024-08-03 19:44:56 | 2024-08-03 19:44:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=65;
typedef array<int,N> info;
info operator+(info x,info y){
for(int i=0;i<N;i++)x[i]+=y[i];
return x;
}
void mv(info &x){
for(int i=N-1;i>=1;i--)x[i]=x[i-1];
x[0]=1;
}
info dfs(int len){
int mid=(1+len)/2;
info p{0};
if(mid>=3)p=dfs(mid);
if(len-mid+1>=3)p=p+dfs(len-mid+1);
mv(p);
return p;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<int> a(n+1);
info dp{0};
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<n;i++){
info now{0},dp2{0};
if(a[i+1]-a[i]+1>=3)now=dfs(a[i+1]-a[i]+1);
mv(now);
// cout<<"i="<<i<<endl;
// for(int j=0;j<5;j++){
// cout<<now[j]<<" \n"[j==4];
// }
for(int j=0;j<N;j++){
for(int k=j;k<N;k++)if(dp[j]+now[k]>dp2[k]&&now[k]>0)dp2[k]=dp[j]+now[k]+(k!=j);
}
dp=dp2;
}
dp[0]++;
int ans=0;
for(int i=0;i<N;i++)if(dp[i])ans=max(ans,dp[i]);
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
7 7 41 53 58 75 78 81
output:
11
result:
wrong answer 1st lines differ - expected: '22', found: '11'