QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620595#4629. Longest Increasing SubsequencehuaxiamengjinWA 1ms5684kbC++14673b2024-10-07 19:33:302024-10-07 19:33:34

Judging History

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

  • [2024-10-07 19:33:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5684kb
  • [2024-10-07 19:33:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n,a[100100];
int ans;
int c[100100][31];
int f[100100][31];
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<=30;j++)
		if(x>(1ll<<j))c[i][j]=1ll<<j,x-=1ll<<j;
		else {c[i][j]=x;break;}
//		for (int j=0;j<=4;j++)
//		cout<<i<<" "<<j<<" "<<c[i][j]<<"\n"; 
	}
	for (int i=1;i<n;i++){
		for (int j=0;j<=30;j++){
			f[i][j]=i-1+c[i][j]+1;
			for (int k=0;k<=j;k++)
			f[i][j]=max(f[i][j],f[i-1][k]+c[i][j]+(j>k)); 
		}
	}
	for (int j=0;j<=30;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: 1ms
memory: 5684kb

input:

7
7 41 53 58 75 78 81

output:

23

result:

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