結果

問題 No.783 門松計画
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-29 09:45:42
言語 Ruby
(3.2.2)
結果
AC  
実行時間 1,641 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 11,604 KB
実行使用メモリ 22,984 KB
最終ジャッジ日時 2023-09-30 18:43:18
合計ジャッジ時間 18,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 217 ms
22,720 KB
testcase_01 AC 245 ms
22,716 KB
testcase_02 AC 219 ms
22,876 KB
testcase_03 AC 140 ms
22,716 KB
testcase_04 AC 191 ms
22,784 KB
testcase_05 AC 191 ms
22,816 KB
testcase_06 AC 191 ms
22,952 KB
testcase_07 AC 217 ms
22,948 KB
testcase_08 AC 195 ms
22,736 KB
testcase_09 AC 217 ms
22,920 KB
testcase_10 AC 1,448 ms
22,828 KB
testcase_11 AC 1,641 ms
22,900 KB
testcase_12 AC 1,507 ms
22,668 KB
testcase_13 AC 497 ms
22,756 KB
testcase_14 AC 1,010 ms
22,736 KB
testcase_15 AC 1,275 ms
22,960 KB
testcase_16 AC 632 ms
22,848 KB
testcase_17 AC 580 ms
22,592 KB
testcase_18 AC 322 ms
22,740 KB
testcase_19 AC 1,137 ms
22,620 KB
testcase_20 AC 195 ms
22,808 KB
testcase_21 AC 576 ms
22,880 KB
testcase_22 AC 810 ms
22,832 KB
testcase_23 AC 143 ms
22,964 KB
testcase_24 AC 1,291 ms
22,896 KB
testcase_25 AC 842 ms
22,828 KB
testcase_26 AC 726 ms
22,984 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,c=gets.split.map &:to_i
l=gets.split.map &:to_i
w=gets.split.map &:to_i
r=0..50
d=(0..150).map{r.map{[0]*51}}
n.times{|i|n.times{|j|n.times{|k|d[b=w[i]+w[j]+w[k]][y=l[j]][z=l[k]]=[d[b][y][z],(x=l[i])!=z&&0<(x-y)*(z-y)?x+y+z:0].max}}}
r.map{|a|r.map{|x|r.map{|y|n.times{|i|d[b=a+w[i]][y][z=l[i]]=[d[b][y][z],(e=d[a][x][y])>0&&x!=z&&0<(x-y)*(z-y)?e+z:0].max}}}}
p d[0,c+1].map{|f|f.map(&:max).max}.max
0