QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620711#4629. Longest Increasing SubsequencehuaxiamengjinWA 5ms51888kbC++14937b2024-10-07 20:41:172024-10-07 20:41:17

Judging History

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

  • [2024-10-07 20:41:17]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:51888kb
  • [2024-10-07 20:41:17]
  • 提交

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]=min(1ll<<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]);
			f[i][j]=max(f[i][j],f[i-1][j]+c[i][j]+((1ll<<j)!=c[i][j]&&c[i][j]!=0));
			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<=10;j++)
//		cout<<i<<" "<<j<<" "<<f[i][j]<<" "<<c[i][j]<<"\n";
//		cout<<"&&&&&\n";
	}
	for (int j=0;j<=60;j++)
	ans=max(ans,f[n-1][j]);
	cout<<ans<<"\n";
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 51888kb

input:

7
7 41 53 58 75 78 81

output:

23

result:

wrong answer 1st lines differ - expected: '22', found: '23'