結果

問題 No.484 収穫
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-19 15:45:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,077 ms / 3,000 ms
コード長 339 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 77,908 KB
最終ジャッジ日時 2023-09-24 23:28:49
合計ジャッジ時間 15,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,156 KB
testcase_01 AC 82 ms
15,028 KB
testcase_02 AC 84 ms
15,080 KB
testcase_03 AC 84 ms
15,008 KB
testcase_04 AC 86 ms
15,288 KB
testcase_05 AC 82 ms
15,240 KB
testcase_06 AC 83 ms
15,112 KB
testcase_07 AC 81 ms
15,192 KB
testcase_08 AC 81 ms
15,244 KB
testcase_09 AC 93 ms
16,316 KB
testcase_10 AC 94 ms
16,196 KB
testcase_11 AC 95 ms
16,200 KB
testcase_12 AC 1,055 ms
77,720 KB
testcase_13 AC 1,047 ms
77,612 KB
testcase_14 AC 1,054 ms
77,884 KB
testcase_15 AC 1,052 ms
77,840 KB
testcase_16 AC 1,048 ms
77,888 KB
testcase_17 AC 1,052 ms
77,840 KB
testcase_18 AC 1,066 ms
77,908 KB
testcase_19 AC 1,046 ms
77,836 KB
testcase_20 AC 1,077 ms
77,672 KB
testcase_21 AC 1,059 ms
77,700 KB
testcase_22 AC 1,063 ms
77,712 KB
testcase_23 AC 1,055 ms
77,624 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
a=gets.split.map &:to_i
f=2e9
d=(0...n).map{[f]*n}
e=(0...n).map{[f]*n}
d[0][n-1]=e[0][n-1]=0
n.downto(1){|k|
  (n-k).times{|i|
    d[i+1][j=i+k]=[d[i+1][j],[[d[i][j],e[i][j]+k].min,a[i]].max+1].min
    e[i][j-1]=[d[i][j-1],[[d[i][j]+k,e[i][j]].min,a[j]].max+1].min
  }
}
p (0...n).map{|i|[[d[i][i],e[i][i]].min,a[i]].max}.min
0