結果

問題 No.127 門松もどき
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-01-30 15:13:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,371 ms / 5,000 ms
コード長 240 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 11,520 KB
実行使用メモリ 156,424 KB
最終ジャッジ日時 2023-08-25 14:02:53
合計ジャッジ時間 17,837 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,520 KB
testcase_01 AC 84 ms
15,828 KB
testcase_02 AC 83 ms
15,744 KB
testcase_03 AC 84 ms
15,380 KB
testcase_04 AC 1,362 ms
156,324 KB
testcase_05 AC 85 ms
15,176 KB
testcase_06 AC 205 ms
54,704 KB
testcase_07 AC 86 ms
18,872 KB
testcase_08 AC 84 ms
17,220 KB
testcase_09 AC 83 ms
16,672 KB
testcase_10 AC 83 ms
16,564 KB
testcase_11 AC 90 ms
21,856 KB
testcase_12 AC 775 ms
117,700 KB
testcase_13 AC 996 ms
133,552 KB
testcase_14 AC 919 ms
128,300 KB
testcase_15 AC 1,206 ms
148,684 KB
testcase_16 AC 884 ms
126,648 KB
testcase_17 AC 1,002 ms
135,336 KB
testcase_18 AC 848 ms
124,400 KB
testcase_19 AC 563 ms
100,268 KB
testcase_20 AC 572 ms
101,824 KB
testcase_21 AC 330 ms
73,820 KB
testcase_22 AC 1,371 ms
156,424 KB
testcase_23 AC 1,362 ms
156,240 KB
testcase_24 AC 1,054 ms
138,640 KB
testcase_25 AC 1,215 ms
149,476 KB
testcase_26 AC 662 ms
109,380 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).each{|w|(0..n-w).each{|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