結果
問題 | No.349 干支の置き物 |
ユーザー |
![]() |
提出日時 | 2016-06-02 16:41:19 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 144 ms / 2,000 ms |
コード長 | 797 bytes |
コンパイル時間 | 2,230 ms |
コンパイル使用メモリ | 75,336 KB |
実行使用メモリ | 41,568 KB |
最終ジャッジ日時 | 2024-11-17 07:34:43 |
合計ジャッジ時間 | 7,581 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
import java.util.HashMap; import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap<String, Integer> list = new HashMap<String, Integer>(); for (int i = 0; i < n; i++) { String s = sc.next(); if (list.containsKey(s)) { //System.out.println("あるn"); list.put(s, list.get(s) + 1); } else { //System.out.println("ないn"); list.put(s, 1); } } sc.close(); System.out.println(solve(list, (n + 1) / 2) ? "YES" : "NO"); } public static boolean solve (HashMap<String,Integer> list, int lim) { for (String s : list.keySet()) { //System.out.println(list.get("saru") + " , " + lim); if (list.get(s) > lim) return false; } return true; } }