UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214949#3856. 排序drdilyor00ms0kbC++11985b2024-11-24 12:23:212024-11-24 13:15:50

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int n;
int a[500005];
int dp[505][505][505];
signed main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	memset(dp,-0x3f,sizeof(dp));
	dp[1][a[1]][0]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(dp[i-1][j][k]<0)continue;
				if(a[i]>j){
					dp[i][a[i]][j]=max(dp[i][a[i]][j],dp[i-1][j][k]+1);
				}
				else{
					dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k]);
					if(a[i]>k){
						dp[i][a[i]][k]=max(dp[i][a[i]][k],dp[i-1][j][k]);
					}
				}
			}
		}
	}
	int res=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++)res=max(res,dp[n][i][j]);
	}
	cout<<res<<"\n";
	return 0;
}
//look at my code
//my code is amazing

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Memory Limit Exceeded

Test #1:

score: 0
Memory Limit Exceeded

input:

475
319 474 473 472 471 183 108 346 43 466 465 464 168 462 461 309 459 458 457 456 455 38 372 312 94...

output:


result:


Subtask #2:

score: 0
Skipped

Subtask #3:

score: 0
Memory Limit Exceeded

Test #9:

score: 0
Memory Limit Exceeded

input:

499758
77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 ...

output:


result:


Subtask #4:

score: 0
Memory Limit Exceeded

Test #11:

score: 0
Memory Limit Exceeded

input:

466818
447360 121353 327541 289718 71942 242279 307652 438765 78054 253024 190170 21720 292462 72832...

output:


result:


Subtask #5:

score: 0
Skipped