結果

問題 No.127 門松もどき
ユーザー gigurururugigurururu
提出日時 2015-01-15 23:35:34
言語 Python2
(2.7.18)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 522 bytes
コンパイル時間 1,216 ms
コンパイル使用メモリ 7,084 KB
実行使用メモリ 165,956 KB
最終ジャッジ日時 2023-09-04 13:27:00
合計ジャッジ時間 59,081 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,944 KB
testcase_01 AC 12 ms
6,016 KB
testcase_02 AC 11 ms
6,076 KB
testcase_03 AC 11 ms
6,188 KB
testcase_04 TLE -
testcase_05 AC 12 ms
6,012 KB
testcase_06 AC 388 ms
17,264 KB
testcase_07 AC 15 ms
6,200 KB
testcase_08 AC 13 ms
6,108 KB
testcase_09 AC 12 ms
6,000 KB
testcase_10 AC 12 ms
6,088 KB
testcase_11 AC 23 ms
6,456 KB
testcase_12 AC 2,679 ms
84,704 KB
testcase_13 AC 3,674 ms
113,856 KB
testcase_14 AC 3,359 ms
102,156 KB
testcase_15 AC 4,720 ms
140,816 KB
testcase_16 AC 3,239 ms
100,980 KB
testcase_17 AC 3,861 ms
130,048 KB
testcase_18 AC 3,120 ms
104,704 KB
testcase_19 AC 1,853 ms
66,200 KB
testcase_20 AC 1,970 ms
70,220 KB
testcase_21 AC 865 ms
33,892 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 3,946 ms
114,508 KB
testcase_25 AC 4,690 ms
134,472 KB
testcase_26 AC 2,240 ms
69,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=input()
A=map(int,raw_input().split())
dp=[[[None]*N for _ in range(N)] for _ in [0,1]]
for i in range(N):
    dp[0][i][i]=dp[1][i][i]=1
for d in range(1,N):
    for l in range(N-d):
        r=l+d
        if A[l]>=A[r]:
            dp[0][l][r]=dp[0][l][r-1]
        else:
            dp[0][l][r]=max(dp[0][l][r-1],dp[1][l+1][r]+1)
        if A[l]<=A[r]:
            dp[1][l][r]=dp[1][l+1][r]
        else:
            dp[1][l][r]=max(dp[1][l+1][r],dp[0][l][r-1]+1)

print max([dp[0][i][N-1] for i in range(N)]+dp[1][0])
0