結果

問題 No.127 門松もどき
ユーザー parukiparuki
提出日時 2016-09-14 20:18:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 1,245 bytes
コンパイル時間 2,738 ms
コンパイル使用メモリ 165,592 KB
実行使用メモリ 73,212 KB
最終ジャッジ日時 2023-08-25 14:12:58
合計ジャッジ時間 3,709 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 63 ms
73,152 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 9 ms
22,792 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
5,932 KB
testcase_12 AC 34 ms
54,360 KB
testcase_13 AC 46 ms
63,092 KB
testcase_14 AC 41 ms
60,800 KB
testcase_15 AC 59 ms
70,984 KB
testcase_16 AC 39 ms
60,776 KB
testcase_17 AC 39 ms
64,880 KB
testcase_18 AC 39 ms
58,552 KB
testcase_19 AC 22 ms
45,972 KB
testcase_20 AC 22 ms
48,060 KB
testcase_21 AC 14 ms
33,236 KB
testcase_22 AC 59 ms
73,212 KB
testcase_23 AC 54 ms
73,160 KB
testcase_24 AC 50 ms
67,032 KB
testcase_25 AC 56 ms
70,984 KB
testcase_26 AC 31 ms
50,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, A[3001], dp[3001][3001][2];

int main(){
    cin >> N;
    rep(i, N)scanf("%d", &A[i]);
    rep(i, N)rep(j, 2)dp[i][i][j] = 1;

    int ans = 1;
    rep(len, N){
        rep(l, N-len){
            int r = l + len;
            rep(lr, 2){
                int val = dp[l][r][lr];
                if(lr == 0 && l > 0){
                    smax(dp[l-1][r][lr], val);
                    if(A[r] > A[l - 1])smax(dp[l - 1][r][!lr], val + 1), smax(ans, val + 1);
                }
                if(lr == 1 && r < N-1){
                    smax(dp[l][r+1][lr], val);
                    if(A[l] > A[r + 1])smax(dp[l][r + 1][!lr], val + 1), smax(ans, val + 1);
                }
            }
        }
    }
    cout << ans << endl;
}
0