結果

問題 No.349 干支の置き物
ユーザー yagi2yagi2
提出日時 2017-04-20 12:14:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 5,862 ms
コンパイル使用メモリ 72,028 KB
実行使用メモリ 56,232 KB
最終ジャッジ日時 2023-09-27 03:14:14
合計ジャッジ時間 9,278 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,272 KB
testcase_01 AC 119 ms
56,232 KB
testcase_02 AC 117 ms
55,744 KB
testcase_03 AC 121 ms
55,632 KB
testcase_04 AC 124 ms
55,400 KB
testcase_05 AC 119 ms
55,684 KB
testcase_06 AC 121 ms
55,608 KB
testcase_07 AC 121 ms
56,036 KB
testcase_08 AC 122 ms
55,608 KB
testcase_09 AC 124 ms
55,776 KB
testcase_10 AC 120 ms
55,548 KB
testcase_11 AC 125 ms
55,916 KB
testcase_12 AC 121 ms
56,100 KB
testcase_13 AC 121 ms
55,812 KB
testcase_14 AC 121 ms
55,632 KB
testcase_15 AC 123 ms
55,432 KB
testcase_16 AC 123 ms
55,360 KB
testcase_17 AC 123 ms
55,668 KB
testcase_18 AC 124 ms
55,532 KB
testcase_19 AC 118 ms
56,220 KB
testcase_20 AC 116 ms
55,564 KB
testcase_21 AC 117 ms
56,088 KB
testcase_22 AC 120 ms
55,752 KB
testcase_23 AC 118 ms
55,776 KB
testcase_24 AC 118 ms
55,780 KB
testcase_25 AC 119 ms
55,624 KB
testcase_26 AC 122 ms
55,360 KB
testcase_27 AC 124 ms
55,968 KB
testcase_28 AC 126 ms
55,860 KB
testcase_29 AC 123 ms
56,088 KB
testcase_30 AC 123 ms
55,800 KB
testcase_31 AC 123 ms
55,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());

        Map<String, Integer> F = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String input = sc.next();

            if (!F.containsKey(input)) {
                F.put(input, 0);
            }
            F.put(input, F.get(input) + 1);
        }

        int max = -1;
        for (Integer value : F.values()) {
            if (max < value) {
                max = value;
            }
        }

        if (2 * (max - 1) < N) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
0