結果

問題 No.349 干支の置き物
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-20 00:06:46
言語 Java19
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 3,385 ms
コンパイル使用メモリ 73,612 KB
実行使用メモリ 56,212 KB
最終ジャッジ日時 2023-07-25 13:57:49
合計ジャッジ時間 10,163 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
54,040 KB
testcase_01 AC 126 ms
55,548 KB
testcase_02 AC 125 ms
56,068 KB
testcase_03 AC 126 ms
55,816 KB
testcase_04 AC 131 ms
55,660 KB
testcase_05 AC 128 ms
55,952 KB
testcase_06 AC 131 ms
55,768 KB
testcase_07 AC 128 ms
56,148 KB
testcase_08 AC 130 ms
55,976 KB
testcase_09 AC 130 ms
55,916 KB
testcase_10 AC 128 ms
55,820 KB
testcase_11 AC 129 ms
55,656 KB
testcase_12 AC 128 ms
55,632 KB
testcase_13 AC 129 ms
55,916 KB
testcase_14 AC 128 ms
56,156 KB
testcase_15 AC 130 ms
55,916 KB
testcase_16 AC 127 ms
55,992 KB
testcase_17 AC 125 ms
55,548 KB
testcase_18 AC 128 ms
56,212 KB
testcase_19 AC 125 ms
55,808 KB
testcase_20 AC 126 ms
55,692 KB
testcase_21 AC 126 ms
55,752 KB
testcase_22 AC 126 ms
55,780 KB
testcase_23 AC 127 ms
56,148 KB
testcase_24 AC 129 ms
56,012 KB
testcase_25 AC 128 ms
56,048 KB
testcase_26 AC 130 ms
55,688 KB
testcase_27 AC 133 ms
55,704 KB
testcase_28 AC 133 ms
55,888 KB
testcase_29 AC 131 ms
55,900 KB
testcase_30 AC 133 ms
55,996 KB
testcase_31 AC 131 ms
55,536 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