結果

問題 No.3158 Collect Stamps
コンテスト
ユーザー kmmtkm
提出日時 2025-05-11 11:35:17
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 337 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 8,064 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2025-05-11 11:35:41
合計ジャッジ時間 22,262 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 15 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - a
Main.rb:1: warning: assigned but unused variable - k
Syntax OK

ソースコード

diff #

n, m, k = gets.split.map(&:to_i)
a = gets.split.map { |x| x.to_i - 1 }
t = Array.new(n) { gets.split.map(&:to_i) }

lst = []
n.times do |i|
  lst.push(i)
end

if m == 0
  ans = 0
else
  ans = 10 ** 18
end

lst.permutation(m) do |p|
  cost = 0
  (m-1).times do |i|
    cost += t[p[i]][p[i+1]]
  end

  ans = [ans, cost].min
end

puts ans
0