結果

問題 No.127 門松もどき
ユーザー yaoshimaxyaoshimax
提出日時 2015-04-25 17:08:39
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 845 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 6,656 KB
実行使用メモリ 163,864 KB
最終ジャッジ日時 2023-09-18 11:20:46
合計ジャッジ時間 16,024 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,972 KB
testcase_01 AC 12 ms
6,076 KB
testcase_02 AC 11 ms
5,848 KB
testcase_03 AC 11 ms
6,080 KB
testcase_04 RE -
testcase_05 AC 11 ms
5,948 KB
testcase_06 AC 488 ms
18,312 KB
testcase_07 AC 15 ms
6,148 KB
testcase_08 AC 12 ms
6,108 KB
testcase_09 AC 11 ms
6,068 KB
testcase_10 AC 11 ms
5,864 KB
testcase_11 AC 24 ms
6,296 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

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)]

def recL(l,r):
    global dpL
    if dpL[l][r]!=-1:
        return dpL[l][r]
    if l>r:
        return 0
    if l==r:
        dpL[l][r]=1
        return 1
    ans=recL(l,r-1)
    if A[l]<A[r]:
        ans=max(ans,recR(l+1,r)+1)
    dpL[l][r]=ans
    #print "dpL",l,r,"=",dpL[l][r]
    return dpL[l][r]

def recR(l,r):
    global dpR
    if dpR[l][r]!=-1:
        return dpR[l][r]
    if l>r:
        return 0
    if l==r:
        dpR[l][r]=1
        return 1
    ans=recR(l+1,r)
    if A[l]>A[r]:
        ans=max(ans,recL(l,r-1)+1)
    dpR[l][r]=ans
    #print "dpR",l,r,"=",dpR[l][r]
    return dpR[l][r]

ans=0
for i in range(N):
    ans=max(ans,recL(i,N-1))
    ans=max(ans,recR(0,i))
print ans

0