結果

問題 No.783 門松計画
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-19 09:41:17
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,643 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 34 ms
コンパイル使用メモリ 11,536 KB
実行使用メモリ 20,360 KB
最終ジャッジ日時 2023-09-30 18:41:12
合計ジャッジ時間 12,994 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
20,204 KB
testcase_01 AC 189 ms
20,024 KB
testcase_02 AC 124 ms
20,160 KB
testcase_03 AC 95 ms
20,060 KB
testcase_04 AC 100 ms
20,208 KB
testcase_05 AC 116 ms
20,108 KB
testcase_06 AC 104 ms
20,308 KB
testcase_07 AC 104 ms
20,068 KB
testcase_08 AC 94 ms
20,104 KB
testcase_09 AC 118 ms
19,984 KB
testcase_10 AC 1,457 ms
20,096 KB
testcase_11 AC 1,643 ms
20,148 KB
testcase_12 AC 1,512 ms
20,168 KB
testcase_13 AC 509 ms
20,304 KB
testcase_14 AC 995 ms
20,304 KB
testcase_15 AC 497 ms
20,272 KB
testcase_16 AC 220 ms
20,248 KB
testcase_17 AC 527 ms
20,216 KB
testcase_18 AC 131 ms
20,320 KB
testcase_19 AC 829 ms
20,088 KB
testcase_20 AC 131 ms
20,360 KB
testcase_21 AC 210 ms
20,180 KB
testcase_22 AC 238 ms
20,308 KB
testcase_23 AC 108 ms
20,292 KB
testcase_24 AC 605 ms
20,148 KB
testcase_25 AC 401 ms
20,204 KB
testcase_26 AC 598 ms
20,300 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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