結果

問題 No.127 門松もどき
ユーザー ctyl_0ctyl_0
提出日時 2015-12-28 00:26:42
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,422 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 91,184 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 11:25:53
合計ジャッジ時間 2,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 40 ms
4,348 KB
testcase_05 WA -
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 20 ms
4,348 KB
testcase_13 AC 26 ms
4,348 KB
testcase_14 AC 24 ms
4,348 KB
testcase_15 AC 33 ms
4,348 KB
testcase_16 AC 23 ms
4,348 KB
testcase_17 AC 18 ms
4,348 KB
testcase_18 AC 17 ms
4,348 KB
testcase_19 AC 10 ms
4,348 KB
testcase_20 AC 10 ms
4,348 KB
testcase_21 AC 6 ms
4,348 KB
testcase_22 AC 39 ms
4,348 KB
testcase_23 AC 32 ms
4,348 KB
testcase_24 AC 32 ms
4,348 KB
testcase_25 AC 37 ms
4,348 KB
testcase_26 AC 19 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    
    vector<vector<int>> dpl(2, vector<int>(N, 1)), dpr(2, vector<int>(N, 1));
    
    int ret = 0;
    repd(i, 1, N){
        rep(j, N - i){
            dpl[0][j] = dpl[1][j];
            if (A[j] < A[i + j]) {
                dpl[0][j] = max(dpl[0][j], dpr[1][j + 1] + 1);
            }
            dpr[0][j] = dpr[1][j + 1];
            if (A[j] > A[i + j]) {
                dpr[0][j] = max(dpl[1][j] + 1, dpr[0][j]);
            }
            ret = max(ret, max(dpl[0][j], dpr[0][j]));
        }
        dpl[1] = dpl[0];
        dpr[1] = dpr[0];
    }
    output(ret, 0);
    
    return 0;
}
0