結果

問題 No.349 干支の置き物
ユーザー samplelpmassamplelpmas
提出日時 2016-12-27 18:52:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 867 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 73,656 KB
実行使用メモリ 56,160 KB
最終ジャッジ日時 2023-08-21 15:22:31
合計ジャッジ時間 7,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,596 KB
testcase_01 AC 123 ms
55,888 KB
testcase_02 AC 124 ms
55,904 KB
testcase_03 AC 123 ms
55,644 KB
testcase_04 AC 128 ms
55,884 KB
testcase_05 AC 127 ms
55,620 KB
testcase_06 AC 128 ms
55,908 KB
testcase_07 AC 128 ms
55,404 KB
testcase_08 AC 132 ms
55,908 KB
testcase_09 AC 130 ms
55,628 KB
testcase_10 AC 128 ms
55,832 KB
testcase_11 AC 130 ms
55,912 KB
testcase_12 AC 129 ms
55,744 KB
testcase_13 AC 131 ms
56,076 KB
testcase_14 AC 129 ms
55,600 KB
testcase_15 AC 129 ms
55,924 KB
testcase_16 AC 128 ms
55,732 KB
testcase_17 AC 124 ms
55,888 KB
testcase_18 AC 123 ms
55,900 KB
testcase_19 AC 123 ms
55,916 KB
testcase_20 AC 124 ms
55,628 KB
testcase_21 AC 127 ms
55,888 KB
testcase_22 AC 127 ms
55,964 KB
testcase_23 AC 126 ms
55,588 KB
testcase_24 AC 125 ms
55,428 KB
testcase_25 AC 127 ms
55,576 KB
testcase_26 AC 130 ms
55,860 KB
testcase_27 AC 131 ms
55,840 KB
testcase_28 AC 129 ms
55,752 KB
testcase_29 AC 129 ms
56,160 KB
testcase_30 AC 130 ms
55,724 KB
testcase_31 AC 129 ms
55,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        Map<String, Integer> zodiac = new HashMap<String, Integer>();

        for (int i = 0; i < N; i ++) {

            String animal = sc.next();

            if (zodiac.containsKey(animal)) {
                zodiac.put(animal , zodiac.get(animal) + 1);
            } else {
                zodiac.put(animal, 1);
            }

        }

        int animalMax = 0;

        for (int numAnimal : zodiac.values()) {
            animalMax = Math.max(animalMax, numAnimal);
        }

        if (animalMax - 1  <= N - animalMax) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

}
0