QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50895#4629. Longest Increasing SubsequenceAppleblue17WA 2ms3644kbC++14764b2022-09-29 16:16:412022-09-29 16:16:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-29 16:16:45]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3644kb
  • [2022-09-29 16:16:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long N=1e5+5,M=66;
long long n,m=60;
long long a[N];
long long dp[N][M];

int main(){
	cin>>n; n--;
	for(long long i=0;i<=n;i++) cin>>a[i];
	dp[0][0]=1;
	for(long long i=1;i<=n;i++){
		long long x=a[i]-a[i-1];
		long long t=0;
		while((1ll<<(t+1))<x) t++;
		
		long long c=x-(1ll<<t),s;
		if(c<=(1ll<<(t-1))) s=(1ll<<(t-1))+1;
		else s=min(1ll<<t,c+1);
		
		for(long long j=0;j<=m;j++){
			for(long long k=0;k<j;k++){
				long long l=k+1,r=j,w;
				if(r==0) w=1;
				else if(r<=t) w=1ll<<(t-1);
				else if(l==t+1) w=c;
				else w=s;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+w);
			}
		}
//		for(long long j=0;j<=m;j++) cout<<dp[i][j]<<" ";
//		cout<<endl;
	}
	cout<<dp[n][m];
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3644kb

input:

7
7 41 53 58 75 78 81

output:

39

result:

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