結果

問題 No.349 干支の置き物
ユーザー jp_stejp_ste
提出日時 2016-05-05 15:56:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 3,958 ms
コンパイル使用メモリ 81,520 KB
実行使用メモリ 41,740 KB
最終ジャッジ日時 2024-04-28 14:48:07
合計ジャッジ時間 9,019 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,588 KB
testcase_01 AC 121 ms
39,956 KB
testcase_02 AC 130 ms
41,740 KB
testcase_03 AC 131 ms
41,164 KB
testcase_04 AC 123 ms
40,216 KB
testcase_05 AC 121 ms
40,332 KB
testcase_06 AC 133 ms
40,960 KB
testcase_07 AC 136 ms
41,260 KB
testcase_08 AC 140 ms
41,184 KB
testcase_09 AC 123 ms
40,184 KB
testcase_10 AC 117 ms
39,776 KB
testcase_11 AC 134 ms
40,928 KB
testcase_12 AC 134 ms
41,232 KB
testcase_13 AC 136 ms
41,220 KB
testcase_14 AC 135 ms
41,176 KB
testcase_15 AC 134 ms
41,180 KB
testcase_16 AC 137 ms
41,280 KB
testcase_17 AC 130 ms
41,000 KB
testcase_18 AC 130 ms
41,184 KB
testcase_19 AC 132 ms
41,156 KB
testcase_20 AC 135 ms
41,192 KB
testcase_21 AC 137 ms
41,068 KB
testcase_22 AC 133 ms
41,584 KB
testcase_23 AC 121 ms
40,032 KB
testcase_24 AC 132 ms
41,536 KB
testcase_25 AC 134 ms
40,904 KB
testcase_26 AC 139 ms
41,304 KB
testcase_27 AC 136 ms
41,012 KB
testcase_28 AC 135 ms
40,836 KB
testcase_29 AC 138 ms
41,192 KB
testcase_30 AC 135 ms
40,672 KB
testcase_31 AC 138 ms
41,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main2 {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int N = scan.nextInt();
            HashMap<String, Integer> map = new HashMap<>();
            for(int i=0; i<N; i++) {
                String key = scan.next();
                Integer value = map.get(key);
                if(value == null) {
                    map.put(key, 1);
                } else {
                    map.replace(key, value+1);
                }                
            }
            
            int max = 0;
            for(Entry<String, Integer> e : map.entrySet()) {
                max = Math.max(max, e.getValue());
            }
            
            if((N+1)/2 >= max) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}
0