結果

問題 No.349 干支の置き物
ユーザー spaciaspacia
提出日時 2016-06-02 16:41:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 76,084 KB
実行使用メモリ 41,556 KB
最終ジャッジ日時 2024-04-28 14:50:59
合計ジャッジ時間 6,421 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
40,104 KB
testcase_01 AC 115 ms
41,272 KB
testcase_02 AC 103 ms
40,204 KB
testcase_03 AC 122 ms
41,260 KB
testcase_04 AC 119 ms
41,356 KB
testcase_05 AC 113 ms
41,508 KB
testcase_06 AC 113 ms
40,984 KB
testcase_07 AC 103 ms
40,092 KB
testcase_08 AC 122 ms
41,148 KB
testcase_09 AC 113 ms
41,192 KB
testcase_10 AC 108 ms
40,428 KB
testcase_11 AC 118 ms
41,408 KB
testcase_12 AC 121 ms
40,952 KB
testcase_13 AC 119 ms
41,232 KB
testcase_14 AC 121 ms
41,136 KB
testcase_15 AC 112 ms
41,228 KB
testcase_16 AC 104 ms
39,836 KB
testcase_17 AC 117 ms
41,028 KB
testcase_18 AC 121 ms
40,120 KB
testcase_19 AC 113 ms
40,908 KB
testcase_20 AC 118 ms
41,148 KB
testcase_21 AC 112 ms
41,556 KB
testcase_22 AC 111 ms
40,852 KB
testcase_23 AC 111 ms
41,128 KB
testcase_24 AC 100 ms
40,084 KB
testcase_25 AC 116 ms
41,524 KB
testcase_26 AC 124 ms
41,360 KB
testcase_27 AC 118 ms
40,080 KB
testcase_28 AC 106 ms
40,176 KB
testcase_29 AC 113 ms
41,260 KB
testcase_30 AC 117 ms
41,248 KB
testcase_31 AC 104 ms
40,116 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