結果

問題 No.349 干支の置き物
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-20 00:06:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 76,636 KB
実行使用メモリ 54,384 KB
最終ジャッジ日時 2024-04-10 06:20:13
合計ジャッジ時間 7,385 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
54,284 KB
testcase_01 AC 108 ms
52,868 KB
testcase_02 AC 110 ms
53,028 KB
testcase_03 AC 119 ms
53,908 KB
testcase_04 AC 128 ms
54,256 KB
testcase_05 AC 119 ms
54,208 KB
testcase_06 AC 123 ms
54,252 KB
testcase_07 AC 127 ms
54,180 KB
testcase_08 AC 120 ms
54,024 KB
testcase_09 AC 124 ms
54,028 KB
testcase_10 AC 125 ms
54,084 KB
testcase_11 AC 124 ms
54,028 KB
testcase_12 AC 129 ms
54,280 KB
testcase_13 AC 126 ms
54,176 KB
testcase_14 AC 114 ms
53,060 KB
testcase_15 AC 126 ms
54,012 KB
testcase_16 AC 126 ms
54,324 KB
testcase_17 AC 112 ms
52,824 KB
testcase_18 AC 121 ms
54,160 KB
testcase_19 AC 126 ms
54,072 KB
testcase_20 AC 124 ms
54,028 KB
testcase_21 AC 122 ms
54,132 KB
testcase_22 AC 122 ms
54,068 KB
testcase_23 AC 117 ms
54,216 KB
testcase_24 AC 110 ms
53,352 KB
testcase_25 AC 118 ms
54,296 KB
testcase_26 AC 131 ms
54,304 KB
testcase_27 AC 131 ms
54,384 KB
testcase_28 AC 120 ms
54,012 KB
testcase_29 AC 129 ms
54,316 KB
testcase_30 AC 112 ms
52,824 KB
testcase_31 AC 124 ms
53,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashMap<String, Integer> map = new HashMap<String, Integer>();
    for(int i = 0; i < N; i++) {
      String s = sc.next();
      if(map.containsKey(s)) {
        map.put(s, map.get(s) + 1);
      } else {
        map.put(s, 1);
      }
    }
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(String s : map.keySet()) {
      list.add(map.get(s));
    }
    Collections.sort(list);
    int max = list.get(list.size() - 1);
    String ans = "NO";
    int sum = 0;
    for(int i = 0; i < list.size() - 1; i++) {
      sum += list.get(i);
    }
    if(sum >= max - 1) ans = "YES";
    System.out.println(ans);
  }
}
0