QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620665#4629. Longest Increasing SubsequencehuaxiamengjinWA 0ms54624kbC++14821b2024-10-07 20:11:012024-10-07 20:11:01

Judging History

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

  • [2024-10-07 20:11:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:54624kb
  • [2024-10-07 20:11:01]
  • 提交

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]=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]);
			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<=5;j++)
//		cout<<i<<" "<<j<<" "<<f[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: 100
Accepted
time: 0ms
memory: 53976kb

input:

7
7 41 53 58 75 78 81

output:

22

result:

ok single line: '22'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 54624kb

input:

8
174 223 259 368 618 738 893 1810

output:

670

result:

wrong answer 1st lines differ - expected: '671', found: '670'