結果

問題 No.1279 Array Battle
ユーザー ktachibanaktachibana
提出日時 2020-11-11 20:39:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 16,708 KB
最終ジャッジ日時 2023-09-30 00:53:46
合計ジャッジ時間 5,270 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,312 KB
testcase_01 AC 82 ms
15,080 KB
testcase_02 AC 79 ms
15,072 KB
testcase_03 AC 75 ms
15,076 KB
testcase_04 AC 76 ms
15,184 KB
testcase_05 AC 76 ms
15,140 KB
testcase_06 AC 76 ms
15,080 KB
testcase_07 AC 77 ms
15,236 KB
testcase_08 AC 76 ms
15,192 KB
testcase_09 AC 76 ms
15,144 KB
testcase_10 AC 76 ms
15,028 KB
testcase_11 AC 76 ms
15,240 KB
testcase_12 AC 82 ms
15,204 KB
testcase_13 AC 131 ms
15,768 KB
testcase_14 AC 127 ms
15,768 KB
testcase_15 AC 563 ms
16,552 KB
testcase_16 AC 579 ms
16,708 KB
testcase_17 AC 584 ms
16,692 KB
testcase_18 AC 589 ms
16,552 KB
testcase_19 AC 585 ms
16,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

io = STDIN
io.gets
aa = io.gets.split(' ').map(&:to_i)
ba = io.gets.split(' ').map(&:to_i)

max = 0
aa.sort.reverse.zip(ba.sort) do |a, b|
  point = a - b
  max += point.positive? ? point : 0
end

count = 0
aa.permutation do |a_seq|
  sum = 0
  a_seq.zip(ba) do |a, b|
    point = a - b
    sum += point if point.positive?
  end
  count += 1 if sum == max
end

puts count
0