結果

問題 No.127 門松もどき
ユーザー gigurururugigurururu
提出日時 2015-01-15 23:42:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,877 ms / 5,000 ms
コード長 307 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 11,528 KB
実行使用メモリ 156,380 KB
最終ジャッジ日時 2023-08-25 13:48:42
合計ジャッジ時間 21,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,156 KB
testcase_01 AC 80 ms
15,276 KB
testcase_02 AC 79 ms
15,044 KB
testcase_03 AC 82 ms
15,124 KB
testcase_04 AC 1,877 ms
156,380 KB
testcase_05 AC 80 ms
15,044 KB
testcase_06 AC 193 ms
26,176 KB
testcase_07 AC 82 ms
15,052 KB
testcase_08 AC 82 ms
15,260 KB
testcase_09 AC 82 ms
15,252 KB
testcase_10 AC 81 ms
15,312 KB
testcase_11 AC 85 ms
15,428 KB
testcase_12 AC 935 ms
89,228 KB
testcase_13 AC 1,274 ms
114,768 KB
testcase_14 AC 1,156 ms
105,868 KB
testcase_15 AC 1,627 ms
141,324 KB
testcase_16 AC 1,091 ms
103,004 KB
testcase_17 AC 1,296 ms
117,476 KB
testcase_18 AC 1,046 ms
99,608 KB
testcase_19 AC 646 ms
66,532 KB
testcase_20 AC 654 ms
68,400 KB
testcase_21 AC 330 ms
39,536 KB
testcase_22 AC 1,866 ms
156,128 KB
testcase_23 AC 1,844 ms
156,068 KB
testcase_24 AC 1,385 ms
123,108 KB
testcase_25 AC 1,640 ms
142,864 KB
testcase_26 AC 797 ms
77,900 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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