結果

問題 No.349 干支の置き物
ユーザー spaciaspacia
提出日時 2016-06-02 16:41:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 3,428 ms
コンパイル使用メモリ 72,564 KB
実行使用メモリ 56,248 KB
最終ジャッジ日時 2023-08-10 21:46:56
合計ジャッジ時間 7,113 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,888 KB
testcase_01 AC 117 ms
55,760 KB
testcase_02 AC 119 ms
56,020 KB
testcase_03 AC 123 ms
55,644 KB
testcase_04 AC 124 ms
55,860 KB
testcase_05 AC 123 ms
56,068 KB
testcase_06 AC 125 ms
55,708 KB
testcase_07 AC 124 ms
55,848 KB
testcase_08 AC 122 ms
55,720 KB
testcase_09 AC 123 ms
56,140 KB
testcase_10 AC 121 ms
55,988 KB
testcase_11 AC 122 ms
55,648 KB
testcase_12 AC 120 ms
55,788 KB
testcase_13 AC 120 ms
55,592 KB
testcase_14 AC 120 ms
55,812 KB
testcase_15 AC 122 ms
55,972 KB
testcase_16 AC 121 ms
55,864 KB
testcase_17 AC 119 ms
55,832 KB
testcase_18 AC 114 ms
55,700 KB
testcase_19 AC 120 ms
55,868 KB
testcase_20 AC 119 ms
56,248 KB
testcase_21 AC 118 ms
55,584 KB
testcase_22 AC 120 ms
55,520 KB
testcase_23 AC 117 ms
55,788 KB
testcase_24 AC 118 ms
55,504 KB
testcase_25 AC 117 ms
55,800 KB
testcase_26 AC 122 ms
55,628 KB
testcase_27 AC 125 ms
56,032 KB
testcase_28 AC 122 ms
56,196 KB
testcase_29 AC 123 ms
56,060 KB
testcase_30 AC 121 ms
56,204 KB
testcase_31 AC 119 ms
56,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
	}

}
0