結果

問題 No.127 門松もどき
ユーザー kurenaifkurenaif
提出日時 2016-02-26 01:25:04
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,170 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 73,572 KB
実行使用メモリ 74,036 KB
最終ジャッジ日時 2023-10-23 20:12:06
合計ジャッジ時間 2,977 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
74,008 KB
testcase_01 AC 19 ms
74,008 KB
testcase_02 AC 18 ms
74,008 KB
testcase_03 AC 19 ms
74,008 KB
testcase_04 AC 98 ms
74,036 KB
testcase_05 WA -
testcase_06 AC 22 ms
74,016 KB
testcase_07 AC 19 ms
74,012 KB
testcase_08 AC 19 ms
74,012 KB
testcase_09 AC 19 ms
74,012 KB
testcase_10 AC 18 ms
74,012 KB
testcase_11 AC 19 ms
74,012 KB
testcase_12 AC 59 ms
74,036 KB
testcase_13 AC 73 ms
74,036 KB
testcase_14 AC 69 ms
74,036 KB
testcase_15 AC 90 ms
74,036 KB
testcase_16 AC 67 ms
74,036 KB
testcase_17 AC 75 ms
74,036 KB
testcase_18 AC 65 ms
74,036 KB
testcase_19 AC 45 ms
74,020 KB
testcase_20 AC 46 ms
74,020 KB
testcase_21 AC 29 ms
74,020 KB
testcase_22 AC 98 ms
74,036 KB
testcase_23 AC 97 ms
74,036 KB
testcase_24 AC 79 ms
74,036 KB
testcase_25 AC 90 ms
74,036 KB
testcase_26 AC 52 ms
74,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int bitcount(long bits)
{
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}

int dpL[3001][3001];
int dpR[3001][3001];

int main(void) {
	int N; cin >> N;
	vector<int> A;
	REP(i, N) {
		int a; cin >> a; A.push_back(a);
	}


	memset(dpL, -1, sizeof(dpL));
	memset(dpR, -1, sizeof(dpR));

	for (int i = 0; i < N; ++i) {
		dpL[i][i] = dpR[i][i] = 1;
	}

	int res = 0;

	for (int w = 1; w < N; ++w) { //幅で更新していくといい感じになった
		for (int l = 0; l < N - w; ++l) {
			int r = l + w;
			if (A[l] >= A[r]) dpL[l][r] = dpL[l][r - 1];
			else {
				dpL[l][r] = max(dpL[l][r - 1], dpR[l + 1][r] + 1);
			}
			if (A[l] <= A[r]) dpR[l][r] = dpR[l + 1][r];
			else {
				dpR[l][r] = max(dpR[l + 1][r], dpL[l][r - 1] + 1);
			}
			res = max(res, dpL[l][r]);
			res = max(res, dpR[l][r]);
		}
	}

	cout << res << endl;

	return 0;
}
0