結果

問題 No.127 門松もどき
ユーザー gigurururugigurururu
提出日時 2015-01-16 22:21:57
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,117 ms / 5,000 ms
コード長 363 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,564 KB
実行使用メモリ 109,344 KB
最終ジャッジ日時 2023-08-25 13:53:01
合計ジャッジ時間 14,498 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,148 KB
testcase_01 AC 78 ms
15,252 KB
testcase_02 AC 75 ms
15,304 KB
testcase_03 AC 75 ms
15,112 KB
testcase_04 AC 1,117 ms
109,344 KB
testcase_05 AC 76 ms
15,256 KB
testcase_06 AC 163 ms
27,172 KB
testcase_07 AC 77 ms
15,032 KB
testcase_08 AC 77 ms
15,356 KB
testcase_09 AC 74 ms
15,076 KB
testcase_10 AC 77 ms
15,088 KB
testcase_11 AC 80 ms
15,672 KB
testcase_12 AC 618 ms
71,124 KB
testcase_13 AC 794 ms
88,464 KB
testcase_14 AC 776 ms
83,620 KB
testcase_15 AC 978 ms
101,728 KB
testcase_16 AC 709 ms
81,156 KB
testcase_17 AC 815 ms
90,000 KB
testcase_18 AC 689 ms
78,472 KB
testcase_19 AC 442 ms
55,468 KB
testcase_20 AC 444 ms
56,624 KB
testcase_21 AC 249 ms
38,276 KB
testcase_22 AC 1,114 ms
109,276 KB
testcase_23 AC 1,075 ms
109,288 KB
testcase_24 AC 870 ms
93,560 KB
testcase_25 AC 1,011 ms
102,544 KB
testcase_26 AC 526 ms
63,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N=gets.to_i
A=gets.split.map(&:to_i)
dpR=[pdpR=[1]*N]
dpL=[pdpL=[1]*N]
(1...N).each{|d|
  dpRd=[]
  dpLd=[]
  (0...N-d).each{|l|
    r=l+d
    dpl=pdpL[l]
    dpr=pdpR[l+1]
    dpLd<<(A[l]>=A[r]?dpl:[dpl,dpr+1].max)
    dpRd<<(A[l]<=A[r]?dpr:[dpr,dpl+1].max)
  }
  dpR<<(pdpR=dpRd)
  dpL<<(pdpL=dpLd)
}
p ((0...N).map{|i|dpL[i][-1]}+(0...N).map{|i|dpR[i][0]}).max
0