結果

問題 No.127 門松もどき
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-02-21 00:20:38
言語 Ruby
(3.2.2)
結果
AC  
実行時間 1,420 ms / 5,000 ms
コード長 238 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 11,576 KB
実行使用メモリ 206,308 KB
最終ジャッジ日時 2023-08-25 14:05:28
合計ジャッジ時間 18,050 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
15,548 KB
testcase_01 AC 71 ms
15,784 KB
testcase_02 AC 69 ms
15,680 KB
testcase_03 AC 70 ms
15,548 KB
testcase_04 AC 1,380 ms
206,308 KB
testcase_05 AC 68 ms
15,180 KB
testcase_06 AC 203 ms
60,992 KB
testcase_07 AC 71 ms
18,772 KB
testcase_08 AC 72 ms
17,188 KB
testcase_09 AC 71 ms
16,764 KB
testcase_10 AC 71 ms
16,344 KB
testcase_11 AC 79 ms
22,296 KB
testcase_12 AC 787 ms
147,040 KB
testcase_13 AC 1,066 ms
168,952 KB
testcase_14 AC 934 ms
161,076 KB
testcase_15 AC 1,280 ms
192,796 KB
testcase_16 AC 902 ms
158,932 KB
testcase_17 AC 1,079 ms
172,004 KB
testcase_18 AC 879 ms
157,600 KB
testcase_19 AC 601 ms
122,520 KB
testcase_20 AC 614 ms
123,964 KB
testcase_21 AC 330 ms
85,256 KB
testcase_22 AC 1,420 ms
206,280 KB
testcase_23 AC 1,389 ms
206,196 KB
testcase_24 AC 1,114 ms
174,896 KB
testcase_25 AC 1,289 ms
194,140 KB
testcase_26 AC 748 ms
133,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i+1
a=[0]+gets.split.map(&:to_i)+[0]
l=(0..n).map{[0]*3005}
r=(0..n).map{[0]*3005}
(1..n).map{|w|(0..n-w).map{|i|s=a[i]-a[i+w];x=l[w-1][i+1];y=r[w-1][i];l[w][i]=s>0?y<x ?x:y+1:x;r[w][i]=s<0?x<y ?y:x+1:y}}
p [l[n][0],r[n][0]].max
0