結果

問題 No.127 門松もどき
ユーザー mayoko_mayoko_
提出日時 2015-01-14 08:50:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 73,132 KB
実行使用メモリ 74,452 KB
最終ジャッジ日時 2023-09-04 12:50:23
合計ジャッジ時間 3,610 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
74,172 KB
testcase_01 AC 30 ms
74,112 KB
testcase_02 AC 31 ms
74,104 KB
testcase_03 AC 30 ms
74,164 KB
testcase_04 WA -
testcase_05 AC 30 ms
74,120 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000000

using namespace std;
typedef long long ll;

const int MAXN = 3010;
int A[MAXN];
int dpL[MAXN][MAXN];
int dpR[MAXN][MAXN];

int main(void) {
    int N;
    int ret = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) {
        dpL[i][j] = dpR[i][j] = 1;
    }
    for (int w = 1; w < N; w++) {
        for (int x = 0; x+w < N; x++) {
            dpL[x][x+w] = max(dpL[x][x+w], dpL[x][x+w-1]);
            dpR[x][x+w] = max(dpR[x][x+w], dpR[x][x+w-1]);
            if (A[x] < A[x+w]) {
                dpL[x][x+w] = max(dpL[x][x+w], 1 + dpR[x+1][x+w]);
            }
            if (A[x] > A[x+w]) {
                dpR[x][x+w] = max(dpR[x][x+w], dpL[x][x+w-1]+1);
            }
            ret = max(ret, max(dpL[x][x+w], dpR[x][x+w]));
        }
    }
    cout << ret << endl;
    return 0;
}
0