結果

問題 No.127 門松もどき
ユーザー yaoshimaxyaoshimax
提出日時 2015-04-26 09:06:58
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 608 ms / 5,000 ms
コード長 536 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 77,400 KB
実行使用メモリ 214,796 KB
最終ジャッジ日時 2023-08-25 14:06:07
合計ジャッジ時間 10,722 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
76,420 KB
testcase_01 AC 65 ms
76,352 KB
testcase_02 AC 65 ms
76,100 KB
testcase_03 AC 69 ms
76,084 KB
testcase_04 AC 580 ms
214,600 KB
testcase_05 AC 65 ms
76,432 KB
testcase_06 AC 123 ms
90,816 KB
testcase_07 AC 86 ms
79,244 KB
testcase_08 AC 74 ms
78,536 KB
testcase_09 AC 71 ms
78,468 KB
testcase_10 AC 71 ms
76,352 KB
testcase_11 AC 86 ms
79,180 KB
testcase_12 AC 330 ms
154,176 KB
testcase_13 AC 416 ms
179,744 KB
testcase_14 AC 386 ms
168,988 KB
testcase_15 AC 538 ms
206,104 KB
testcase_16 AC 405 ms
168,336 KB
testcase_17 AC 420 ms
182,132 KB
testcase_18 AC 364 ms
164,228 KB
testcase_19 AC 258 ms
123,184 KB
testcase_20 AC 258 ms
132,792 KB
testcase_21 AC 165 ms
100,224 KB
testcase_22 AC 600 ms
214,796 KB
testcase_23 AC 608 ms
214,612 KB
testcase_24 AC 429 ms
187,916 KB
testcase_25 AC 527 ms
207,572 KB
testcase_26 AC 284 ms
142,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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