結果
問題 | No.349 干支の置き物 |
ユーザー |
|
提出日時 | 2017-04-27 12:28:09 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 289 bytes |
コンパイル時間 | 77 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-09-13 14:47:40 |
合計ジャッジ時間 | 3,909 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
Syntax OK
ソースコード
n=gets.to_i #number of animals a=$stdin.read.split(?\n).map().sort #array of animals m=0 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