QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620823 | #4629. Longest Increasing Subsequence | huaxiamengjin | Compile Error | / | / | C++14 | 828b | 2024-10-07 21:37:07 | 2024-10-07 21:37:08 |
Judging History
This is the latest submission verdict.
- [2024-10-07 21:37:08]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-07 21:37:07]
- Submitted
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;
memset(f,-63,sizeof(f));
f[0][0]=1;
for (int i=1;i<n;i++){
int x=a[i+1]-a[i];
int len=63^__builtin_clzll(x);
for (int j=0;j<len;j++)c[i][j]=1ll<<j;
c[i][len]=x-(1ll<<len);
for (int j=0;j<len;j++)
for (int k=0;k<=j;k++)
f[i][j]=max(f[i][j],f[i-1][k]+c[i][j]);
f[i][len]=max(f[i][len],f[i-1][len]+c[i][j]);
if(c[i][len]!=0){
int tmp=max(1ll<<len-1,c[i][len])+1;
for (int k=0;k<len;k++)
f[i][len]=max(f[i][len],f[i-1][k]+tmp);
}
for (int j=0;j<=60;j++)
f[i][j]=max(f[i][j],f[i-1][j]);
}
for (int j=0;j<=60;j++)
ans=max(ans,f[n-1][j]);
cout<<ans<<"\n";
}
Details
answer.code: In function ‘int main()’: answer.code:23:58: error: ‘j’ was not declared in this scope 23 | f[i][len]=max(f[i][len],f[i-1][len]+c[i][j]); | ^