結果

問題 No.1279 Array Battle
ユーザー universato
提出日時 2020-12-08 19:00:22
言語 Ruby
(3.4.1)
結果
AC  
実行時間 687 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-09-17 19:59:12
合計ジャッジ時間 6,284 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Main.rb:5: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

n = gets.to_s.to_i
a = gets.to_s.split.map(&:to_i)
b = gets.to_s.split.map(&:to_i)

i = 0
m = 0
ans = 0
a.permutation do |a|
  s = 0
  a.each_with_index do |e, i|
    if e > b[i]
      s += e - b[i]
    end
  end
  if s > m
    ans = 1
    m = s
  elsif s == m
    ans += 1
  end
end

puts ans
0