結果

問題 No.127 門松もどき
ユーザー yaoshimaxyaoshimax
提出日時 2015-04-26 08:49:04
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 538 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 6,700 KB
実行使用メモリ 5,940 KB
最終ジャッジ日時 2023-09-18 11:38:08
合計ジャッジ時間 7,538 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

N=int(raw_input())
A=map(int,raw_input().split())
dpL=[[1 for j in range(N)] for k in range(N)]
dpR=[[1 for j in range(N)] for k in range(N)]
ans=1
for d in range(1,N):
    for l in range(N-d):
        # update l,l+d
        if A[l]<A[l+d]:
            dpL[l][l+d]=max(dpL[l][l+d-1],dpR[l+1][l+d]+1)
            dpR[l][l+d]=dpR[l+1][l+d]
        if A[l]>A[l+d]:
            dpL[l][l+d]=dpL[l][l+d-1]
            dpR[l][l+d]=max(dpR[l+1][l+d],dpL[l][l+d-1]+1)
        ans=max(ans,dpL[l][l+d])
        ans=max(ans,dpR[l][l+d])

print ans


0