結果

問題 No.127 門松もどき
ユーザー 👑 kmjpkmjp
提出日時 2015-01-14 00:45:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 104 ms / 5,000 ms
コード長 1,143 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 145,684 KB
実行使用メモリ 75,116 KB
最終ジャッジ日時 2023-08-25 13:40:31
合計ジャッジ時間 3,506 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,556 KB
testcase_01 AC 2 ms
5,464 KB
testcase_02 AC 2 ms
5,568 KB
testcase_03 AC 2 ms
5,488 KB
testcase_04 AC 103 ms
75,076 KB
testcase_05 AC 2 ms
5,432 KB
testcase_06 AC 11 ms
25,240 KB
testcase_07 AC 2 ms
5,756 KB
testcase_08 AC 2 ms
5,660 KB
testcase_09 AC 3 ms
5,732 KB
testcase_10 AC 2 ms
5,600 KB
testcase_11 AC 3 ms
8,084 KB
testcase_12 AC 59 ms
58,716 KB
testcase_13 AC 75 ms
66,940 KB
testcase_14 AC 70 ms
62,784 KB
testcase_15 AC 93 ms
73,072 KB
testcase_16 AC 68 ms
62,784 KB
testcase_17 AC 76 ms
66,868 KB
testcase_18 AC 65 ms
60,832 KB
testcase_19 AC 41 ms
48,316 KB
testcase_20 AC 43 ms
50,336 KB
testcase_21 AC 21 ms
35,656 KB
testcase_22 AC 102 ms
75,068 KB
testcase_23 AC 104 ms
75,060 KB
testcase_24 AC 82 ms
68,912 KB
testcase_25 AC 95 ms
75,116 KB
testcase_26 AC 52 ms
54,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[10101];
int dp[2][3030][3030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	int ma=1;
	
	cin>>N;
	FOR(i,N) cin>>A[i], dp[0][i][i]=dp[1][i][i]=1;
	
	for(i=1;i<=N;i++) for(x=0;x+i<N;x++) {
		dp[1][x][x+i] = max(dp[1][x][x+i],dp[1][x][x+i-1]);
		dp[0][x][x+i] = max(dp[0][x][x+i],dp[0][x+1][x+i]);
		if(A[x]<A[x+i]) dp[1][x][x+i] = max(dp[1][x][x+i],dp[0][x+1][x+i]+1);
		if(A[x]>A[x+i]) dp[0][x][x+i] = max(dp[0][x][x+i],dp[1][x][x+i-1]+1);
		ma=max(ma,dp[1][x][x+i]);
		ma=max(ma,dp[0][x][x+i]);
	}
	cout<<ma<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0