結果

問題 No.127 門松もどき
ユーザー uenokuuenoku
提出日時 2017-01-08 00:34:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 977 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 80,540 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-09 22:40:18
合計ジャッジ時間 1,959 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,944 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 <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int main()
{
    int n;
    cin >> n;
    int a[3004];
    vector<pair<int, int>> p;
    rep(i, n)
    {
        cin >> a[i];
        p.push_back(make_pair(a[i], i));
    }
    sort(p.begin(), p.end());
    int dp[3004][2] = {};
    rep(i, n)
    {
        for (int j = p[i].second + 1; j < n; j++) {
            if (a[j] > a[p[i].second])
                dp[j][0] = max(dp[p[i].second][1] + 1, dp[j][0]);
        }
        for (int j = p[i].second - 1; j >= 0; j--) {
            if (a[j] > a[p[i].second])
                dp[j][1] = max(dp[p[i].second][0] + 1, dp[j][1]);
        }
    }
    int ans = 0;
    rep(i, n) rep(j, 2) ans = max(dp[i][j], ans);
    cout << ans + 1 << endl;
}
0