結果

問題 No.349 干支の置き物
ユーザー GrenacheGrenache
提出日時 2016-03-11 22:26:01
言語 Java19
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 72,928 KB
実行使用メモリ 56,312 KB
最終ジャッジ日時 2023-08-10 21:33:01
合計ジャッジ時間 8,516 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,640 KB
testcase_01 AC 122 ms
55,264 KB
testcase_02 AC 121 ms
55,644 KB
testcase_03 AC 120 ms
55,876 KB
testcase_04 AC 125 ms
55,296 KB
testcase_05 AC 120 ms
55,528 KB
testcase_06 AC 122 ms
55,900 KB
testcase_07 AC 120 ms
55,632 KB
testcase_08 AC 126 ms
55,908 KB
testcase_09 AC 120 ms
56,312 KB
testcase_10 AC 122 ms
55,304 KB
testcase_11 AC 126 ms
55,676 KB
testcase_12 AC 125 ms
55,716 KB
testcase_13 AC 125 ms
55,540 KB
testcase_14 AC 121 ms
55,520 KB
testcase_15 AC 125 ms
55,640 KB
testcase_16 AC 123 ms
55,728 KB
testcase_17 AC 122 ms
55,544 KB
testcase_18 AC 121 ms
55,812 KB
testcase_19 AC 119 ms
55,616 KB
testcase_20 AC 119 ms
55,908 KB
testcase_21 AC 117 ms
55,680 KB
testcase_22 AC 119 ms
55,648 KB
testcase_23 AC 117 ms
55,544 KB
testcase_24 AC 121 ms
55,672 KB
testcase_25 AC 120 ms
55,548 KB
testcase_26 AC 123 ms
55,840 KB
testcase_27 AC 127 ms
55,272 KB
testcase_28 AC 126 ms
55,648 KB
testcase_29 AC 125 ms
55,992 KB
testcase_30 AC 126 ms
55,536 KB
testcase_31 AC 126 ms
55,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
}
0