結果

問題 No.127 門松もどき
ユーザー 👑 hos.lyrichos.lyric
提出日時 2015-01-30 14:59:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 4,121 ms / 5,000 ms
コード長 226 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 177,704 KB
最終ジャッジ日時 2023-08-25 14:01:27
合計ジャッジ時間 48,059 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,284 KB
testcase_01 AC 84 ms
15,128 KB
testcase_02 AC 81 ms
15,088 KB
testcase_03 AC 82 ms
15,244 KB
testcase_04 AC 4,121 ms
177,572 KB
testcase_05 AC 83 ms
15,100 KB
testcase_06 AC 405 ms
34,116 KB
testcase_07 AC 86 ms
15,504 KB
testcase_08 AC 85 ms
15,256 KB
testcase_09 AC 89 ms
15,088 KB
testcase_10 AC 84 ms
15,076 KB
testcase_11 AC 95 ms
16,140 KB
testcase_12 AC 2,199 ms
97,932 KB
testcase_13 AC 2,902 ms
141,376 KB
testcase_14 AC 2,682 ms
131,992 KB
testcase_15 AC 3,749 ms
169,368 KB
testcase_16 AC 2,567 ms
128,460 KB
testcase_17 AC 3,005 ms
144,204 KB
testcase_18 AC 2,490 ms
124,640 KB
testcase_19 AC 1,536 ms
87,040 KB
testcase_20 AC 1,567 ms
87,644 KB
testcase_21 AC 788 ms
49,356 KB
testcase_22 AC 4,102 ms
177,584 KB
testcase_23 AC 4,093 ms
177,704 KB
testcase_24 AC 3,182 ms
150,456 KB
testcase_25 AC 3,748 ms
170,092 KB
testcase_26 AC 1,843 ms
91,964 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i+1
a=[0]+gets.split.map(&:to_i)+[0]
d=(0..n).map{[0,1].map{(0..n).map{0}}}
(1..n).each{|w|2.times{|s|(0..n-w).each{|i|d[w][s][i]=[d[w-1][s][i+1-s],(-1)**s==(a[i]<=>a[i+w])?1+d[w-1][1-s][i+s]:0].max}}}
p d[n].max.max
0