結果

問題 No.1279 Array Battle
ユーザー pink_bangbipink_bangbi
提出日時 2020-11-11 19:45:37
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 571 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,336 KB
実行使用メモリ 18,748 KB
最終ジャッジ日時 2023-09-30 00:51:10
合計ジャッジ時間 12,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,144 KB
testcase_01 AC 78 ms
15,164 KB
testcase_02 AC 83 ms
15,308 KB
testcase_03 AC 78 ms
15,028 KB
testcase_04 AC 78 ms
15,320 KB
testcase_05 AC 77 ms
15,316 KB
testcase_06 AC 78 ms
15,192 KB
testcase_07 AC 77 ms
15,184 KB
testcase_08 AC 82 ms
15,216 KB
testcase_09 AC 79 ms
15,168 KB
testcase_10 AC 80 ms
15,148 KB
testcase_11 AC 83 ms
15,164 KB
testcase_12 AC 102 ms
15,168 KB
testcase_13 AC 280 ms
15,988 KB
testcase_14 AC 288 ms
15,636 KB
testcase_15 AC 1,886 ms
18,748 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Array
  using Module.new {
    refine Integer do
      def -(other)
        (super other).tap { break 0 if _1 < 0 }
      end
    end
  }
  def battle(other)
    zip(other).map { |a, b| a - b }.sum
  end
end

def calc(inputs)
  a, b = inputs[1..].map { _1.split.map(&:to_i) }
  a.permutation.map { |xs| xs.battle(b) }.then { |result|
    result.count result.max
  }
end

inputs = [
  "3",
  "3 4",
  "1 4"
]
# inputs = [
#   "3",
#   "5 5 5",
#   "7 5 6"
# ]
# inputs = [
#   "5",
#   "6 5 5 4 4",
#   "1 3 5 7 9"
# ]

inputs = [gets, gets, gets]
puts calc(inputs)
0