結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー yuruhiyayuruhiya
提出日時 2021-01-23 15:29:41
言語 Crystal
(1.11.2)
結果
AC  
実行時間 748 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 17,594 ms
コンパイル使用メモリ 258,704 KB
実行使用メモリ 5,172 KB
最終ジャッジ日時 2023-09-13 13:13:39
合計ジャッジ時間 36,308 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,480 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,420 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,420 KB
testcase_14 AC 3 ms
4,492 KB
testcase_15 AC 3 ms
4,604 KB
testcase_16 AC 3 ms
4,456 KB
testcase_17 AC 3 ms
4,664 KB
testcase_18 AC 2 ms
4,460 KB
testcase_19 AC 4 ms
4,860 KB
testcase_20 AC 3 ms
4,500 KB
testcase_21 AC 2 ms
4,420 KB
testcase_22 AC 3 ms
4,744 KB
testcase_23 AC 72 ms
5,036 KB
testcase_24 AC 152 ms
5,112 KB
testcase_25 AC 748 ms
5,108 KB
testcase_26 AC 9 ms
4,776 KB
testcase_27 AC 6 ms
4,836 KB
testcase_28 AC 734 ms
5,040 KB
testcase_29 AC 35 ms
4,744 KB
testcase_30 AC 71 ms
5,152 KB
testcase_31 AC 71 ms
5,168 KB
testcase_32 AC 17 ms
4,880 KB
testcase_33 AC 728 ms
5,164 KB
testcase_34 AC 728 ms
5,096 KB
testcase_35 AC 719 ms
5,164 KB
testcase_36 AC 723 ms
5,124 KB
testcase_37 AC 721 ms
4,988 KB
testcase_38 AC 716 ms
5,084 KB
testcase_39 AC 717 ms
5,100 KB
testcase_40 AC 719 ms
5,040 KB
testcase_41 AC 726 ms
5,172 KB
testcase_42 AC 726 ms
5,052 KB
testcase_43 AC 3 ms
4,476 KB
testcase_44 AC 722 ms
5,152 KB
testcase_45 AC 3 ms
4,424 KB
testcase_46 AC 721 ms
4,976 KB
権限があれば一括ダウンロードができます

ソースコード

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 = read_line.to_i
a = read_line.split.map(&.to_i64)
b = (1..n).map { read_line.split.map(&.to_i64) }
ans, bit = (1...1 << n).max_of { |bit|
  x = (0...n).select { |i| bit.bit(i) == 1 }
  {x.sum { |i| a[i] } + x.combinations(2).sum { |(i, j)| b[i][j] }, x}
}
puts ans, bit.join(' ', &.+(1))
0