結果

問題 No.349 干支の置き物
ユーザー crazybbb3crazybbb3
提出日時 2017-01-31 21:06:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,447 bytes
コンパイル時間 2,752 ms
コンパイル使用メモリ 82,476 KB
実行使用メモリ 50,416 KB
最終ジャッジ日時 2023-08-25 16:06:21
合計ジャッジ時間 5,670 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
49,792 KB
testcase_01 AC 50 ms
49,868 KB
testcase_02 AC 52 ms
49,892 KB
testcase_03 AC 48 ms
49,876 KB
testcase_04 AC 49 ms
50,000 KB
testcase_05 AC 48 ms
50,416 KB
testcase_06 AC 49 ms
49,836 KB
testcase_07 AC 49 ms
49,844 KB
testcase_08 AC 52 ms
50,200 KB
testcase_09 AC 50 ms
50,016 KB
testcase_10 AC 49 ms
50,164 KB
testcase_11 AC 49 ms
49,836 KB
testcase_12 AC 49 ms
49,876 KB
testcase_13 AC 49 ms
50,416 KB
testcase_14 AC 48 ms
49,920 KB
testcase_15 AC 49 ms
50,288 KB
testcase_16 AC 48 ms
50,412 KB
testcase_17 AC 48 ms
50,148 KB
testcase_18 AC 53 ms
49,888 KB
testcase_19 AC 49 ms
49,840 KB
testcase_20 AC 48 ms
50,276 KB
testcase_21 AC 48 ms
49,816 KB
testcase_22 AC 49 ms
49,816 KB
testcase_23 AC 50 ms
49,800 KB
testcase_24 AC 48 ms
49,924 KB
testcase_25 AC 48 ms
49,828 KB
testcase_26 AC 48 ms
49,920 KB
testcase_27 AC 48 ms
50,296 KB
testcase_28 AC 48 ms
50,068 KB
testcase_29 AC 48 ms
49,980 KB
testcase_30 AC 50 ms
49,840 KB
testcase_31 AC 49 ms
49,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int n = ni();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = ns();
            map.merge(s, 1, (x, y) -> x + y);
        }

        for (int x : map.values()) {
            if (x > (n + 1) / 2) {
                out.println("NO");
                return;
            }
        }
        out.println("YES");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0