結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー universatouniversato
提出日時 2021-01-23 01:29:10
言語 Crystal
(1.14.0)
結果
AC  
実行時間 1,071 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 12,098 ms
コンパイル使用メモリ 296,576 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 22:04:26
合計ジャッジ時間 30,657 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C;fun strtoll(s: UInt8*,p: UInt8**,b: Int32): Int64;end
class String;def to_i64;C.strtoll(self,nil,10);end;end

n = gets.to_s.to_i64
a = gets.to_s.split.map{ |e| e.to_i64 }
b = Array(Array(Int64)).new(n){ |s| gets.to_s.split.map{ |e| e.to_i64 } }

ans = Int64::MIN
ans_cmb = [] of Int64
ia = (0i64...n).to_a
(1..n).each do |i|
  ia.each_combination(i) do |cmb|
    tmp = cmb.sum{ |j| a[j] }
    tmp += cmb.each_combination(2).sum{ |(x, y)|  b[x][y] }
    tmp_cmb = cmb
    if ans < tmp
      ans = tmp
      ans_cmb = tmp_cmb
    end
  end
end

puts ans
puts ans_cmb.map{ |k| k + 1 }.join(' ')
0