結果

問題 No.1279 Array Battle
ユーザー simansiman
提出日時 2020-11-07 13:46:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 888 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,436 KB
実行使用メモリ 15,556 KB
最終ジャッジ日時 2023-09-29 20:33:49
合計ジャッジ時間 6,745 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,116 KB
testcase_01 AC 77 ms
15,036 KB
testcase_02 AC 76 ms
15,296 KB
testcase_03 AC 76 ms
15,148 KB
testcase_04 AC 76 ms
15,120 KB
testcase_05 AC 76 ms
15,236 KB
testcase_06 AC 76 ms
15,104 KB
testcase_07 AC 75 ms
15,136 KB
testcase_08 AC 75 ms
15,128 KB
testcase_09 AC 76 ms
15,004 KB
testcase_10 AC 76 ms
15,132 KB
testcase_11 AC 78 ms
15,108 KB
testcase_12 AC 86 ms
15,364 KB
testcase_13 AC 158 ms
15,248 KB
testcase_14 AC 156 ms
15,244 KB
testcase_15 AC 815 ms
15,532 KB
testcase_16 AC 865 ms
15,544 KB
testcase_17 AC 886 ms
15,556 KB
testcase_18 AC 876 ms
15,528 KB
testcase_19 AC 888 ms
15,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ans = 0
counter = Hash.new(0)

A.permutation(N) do |nums|
  val = 0

  nums.zip(B).each do |a, b|
    next if b >= a

    val += a - b
  end

  counter[val] += 1
  ans = val if ans < val
end

puts counter[ans]
0