QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#620823#4629. Longest Increasing SubsequencehuaxiamengjinCompile Error//C++14828b2024-10-07 21:37:072024-10-07 21:37:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 21:37:08]
  • 评测
  • [2024-10-07 21:37:07]
  • 提交

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";
} 

詳細信息

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]);
      |                                                          ^