結果

問題 No.349 干支の置き物
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-28 21:33:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 4,124 ms
コンパイル使用メモリ 72,836 KB
実行使用メモリ 56,464 KB
最終ジャッジ日時 2023-08-10 21:46:38
合計ジャッジ時間 8,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,856 KB
testcase_01 AC 121 ms
55,812 KB
testcase_02 AC 117 ms
55,980 KB
testcase_03 AC 120 ms
55,720 KB
testcase_04 AC 121 ms
55,848 KB
testcase_05 AC 115 ms
55,616 KB
testcase_06 AC 117 ms
55,308 KB
testcase_07 AC 125 ms
55,988 KB
testcase_08 AC 120 ms
56,012 KB
testcase_09 AC 116 ms
56,224 KB
testcase_10 AC 114 ms
55,748 KB
testcase_11 AC 126 ms
55,572 KB
testcase_12 AC 134 ms
55,816 KB
testcase_13 AC 132 ms
55,640 KB
testcase_14 AC 130 ms
55,732 KB
testcase_15 AC 128 ms
56,124 KB
testcase_16 AC 119 ms
55,472 KB
testcase_17 AC 118 ms
55,320 KB
testcase_18 AC 120 ms
55,788 KB
testcase_19 AC 125 ms
55,276 KB
testcase_20 AC 123 ms
55,544 KB
testcase_21 AC 121 ms
55,284 KB
testcase_22 AC 126 ms
56,108 KB
testcase_23 AC 114 ms
55,720 KB
testcase_24 AC 125 ms
55,912 KB
testcase_25 AC 120 ms
55,712 KB
testcase_26 AC 119 ms
55,804 KB
testcase_27 AC 123 ms
56,464 KB
testcase_28 AC 129 ms
55,844 KB
testcase_29 AC 126 ms
56,280 KB
testcase_30 AC 132 ms
53,936 KB
testcase_31 AC 125 ms
55,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise29{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int size = sc.nextInt();
    String[] eto = new String[size];


    for (int n = 0; n < size; n++){
      eto[n] = sc.next();
    }
    int max = 0;
    for (int n = 0; n < size - 1; n++){
      int count = 1;
      for (int j = n + 1; j < size; j++){
        if (eto[n].equals(eto[j])){
          count++;
        }
      }

      max = Math.max(max, count);
    }

    boolean flag = true;

    if (size % 2 == 0){
      if (max > size / 2){
        flag = false;
      }
    }else{
      if (max > size / 2 + 1){
        flag = false;
      }
    }

    System.out.println(flag ? "YES" : "NO");
  }
}
0