結果

問題 No.349 干支の置き物
ユーザー akko_yukkyakko_yukky
提出日時 2017-04-27 12:22:52
言語 Ruby
(3.4.1)
結果
RE  
実行時間 -
コード長 286 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-09-13 14:47:21
合計ジャッジ時間 4,222 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i #number of animals
a=$stdin.read.split(?\n).map().sort #array of animals

a.each {|str|
  m=(m>a.count(str)? m:a.count(str))
  }

flag = 0

if n%2==0
  if m<=n/2
    flag=1
  end
else
  if m<=(n+1)/2
    flag=1
  end
end

if flag==1
  puts "YES"
elsif flag==0
  puts"NO"
end
0