結果

問題 No.349 干支の置き物
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-28 21:33:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 3,518 ms
コンパイル使用メモリ 75,888 KB
実行使用メモリ 41,976 KB
最終ジャッジ日時 2024-04-28 14:50:44
合計ジャッジ時間 8,868 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,528 KB
testcase_01 AC 133 ms
41,188 KB
testcase_02 AC 122 ms
40,096 KB
testcase_03 AC 133 ms
41,236 KB
testcase_04 AC 138 ms
41,020 KB
testcase_05 AC 138 ms
41,580 KB
testcase_06 AC 140 ms
41,976 KB
testcase_07 AC 141 ms
41,416 KB
testcase_08 AC 140 ms
41,268 KB
testcase_09 AC 145 ms
41,292 KB
testcase_10 AC 136 ms
41,412 KB
testcase_11 AC 142 ms
41,164 KB
testcase_12 AC 140 ms
41,812 KB
testcase_13 AC 139 ms
41,264 KB
testcase_14 AC 141 ms
41,308 KB
testcase_15 AC 139 ms
41,280 KB
testcase_16 AC 136 ms
41,216 KB
testcase_17 AC 134 ms
41,188 KB
testcase_18 AC 133 ms
41,344 KB
testcase_19 AC 134 ms
41,472 KB
testcase_20 AC 138 ms
41,380 KB
testcase_21 AC 120 ms
40,316 KB
testcase_22 AC 136 ms
41,120 KB
testcase_23 AC 133 ms
41,284 KB
testcase_24 AC 131 ms
41,232 KB
testcase_25 AC 135 ms
41,420 KB
testcase_26 AC 121 ms
40,316 KB
testcase_27 AC 135 ms
40,992 KB
testcase_28 AC 134 ms
41,164 KB
testcase_29 AC 137 ms
41,040 KB
testcase_30 AC 137 ms
41,600 KB
testcase_31 AC 118 ms
40,156 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