結果
問題 | No.349 干支の置き物 |
ユーザー |
|
提出日時 | 2016-03-11 22:26:01 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 861 bytes |
コンパイル時間 | 3,546 ms |
コンパイル使用メモリ | 76,072 KB |
実行使用メモリ | 41,652 KB |
最終ジャッジ日時 | 2024-11-17 07:21:22 |
合計ジャッジ時間 | 8,753 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
import java.util.HashMap;import java.util.Map;import java.util.Map.Entry;import java.util.Scanner;public class Main_yukicoder349 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();Map<String, Integer> hm = new HashMap<>();for (int i = 0; i < n; i++) {String s = sc.next();if (hm.containsKey(s)) {hm.put(s, hm.get(s) + 1);} else {hm.put(s, 1);}}boolean flag = true;for (Entry<String, Integer> e : hm.entrySet()) {if (e.getValue() -1 > n - e.getValue()) {flag = false;break;}}if (flag) {System.out.println("YES");} else {System.out.println("NO");}sc.close();}}