結果

問題 No.1060 素敵な宝箱
ユーザー yuruhiyayuruhiya
提出日時 2021-02-15 19:20:00
言語 Crystal
(1.11.2)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 23,518 ms
コンパイル使用メモリ 258,072 KB
実行使用メモリ 6,408 KB
最終ジャッジ日時 2023-09-30 16:47:38
合計ジャッジ時間 25,126 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,452 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 3 ms
4,496 KB
testcase_03 AC 2 ms
4,496 KB
testcase_04 AC 3 ms
4,564 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,396 KB
testcase_07 AC 2 ms
4,420 KB
testcase_08 AC 3 ms
4,676 KB
testcase_09 AC 3 ms
4,560 KB
testcase_10 AC 2 ms
4,628 KB
testcase_11 AC 3 ms
4,592 KB
testcase_12 AC 6 ms
5,288 KB
testcase_13 AC 6 ms
5,404 KB
testcase_14 AC 7 ms
5,556 KB
testcase_15 AC 10 ms
6,372 KB
testcase_16 AC 7 ms
5,612 KB
testcase_17 AC 5 ms
5,108 KB
testcase_18 AC 6 ms
5,376 KB
testcase_19 AC 5 ms
5,272 KB
testcase_20 AC 8 ms
5,588 KB
testcase_21 AC 8 ms
5,484 KB
testcase_22 AC 8 ms
5,560 KB
testcase_23 AC 6 ms
5,216 KB
testcase_24 AC 11 ms
6,408 KB
testcase_25 AC 11 ms
6,352 KB
testcase_26 AC 11 ms
6,344 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, m = read_line.split.map(&.to_i)
a = (1..n).map { read_line.split.map(&.to_i64) }
(0...m).each do |i|
  sum = (0...n).sum { |j| a[j][i] }
  (0...n).each { |j| a[j][i] *= sum }
end
puts a.map(&.sum).sort.reverse.each_slice(2).reduce({0i64, 0i64}) { |acc, x|
  {acc[0] + x[0], acc[1] + x[1]}
}.try { |(x, y)| x - y }
0