結果

問題 No.112 ややこしい鶴亀算
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-23 22:41:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 702 bytes
コンパイル時間 3,306 ms
コンパイル使用メモリ 77,504 KB
実行使用メモリ 42,480 KB
最終ジャッジ日時 2024-04-20 00:01:53
合計ジャッジ時間 7,892 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,760 KB
testcase_01 AC 134 ms
42,228 KB
testcase_02 AC 142 ms
42,024 KB
testcase_03 AC 129 ms
42,464 KB
testcase_04 AC 130 ms
41,952 KB
testcase_05 AC 128 ms
41,912 KB
testcase_06 AC 121 ms
41,804 KB
testcase_07 AC 135 ms
42,480 KB
testcase_08 AC 125 ms
41,920 KB
testcase_09 AC 125 ms
41,896 KB
testcase_10 AC 138 ms
42,212 KB
testcase_11 AC 124 ms
41,788 KB
testcase_12 AC 137 ms
42,340 KB
testcase_13 AC 128 ms
41,568 KB
testcase_14 AC 136 ms
42,196 KB
testcase_15 AC 149 ms
42,380 KB
testcase_16 AC 140 ms
42,268 KB
testcase_17 AC 128 ms
40,700 KB
testcase_18 AC 131 ms
41,524 KB
testcase_19 AC 139 ms
42,372 KB
testcase_20 AC 143 ms
42,064 KB
testcase_21 AC 139 ms
42,440 KB
testcase_22 AC 133 ms
42,464 KB
testcase_23 AC 144 ms
42,336 KB
testcase_24 AC 134 ms
42,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] a = new int[n];
    boolean f = false;
    int bigger = 0;
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      bigger = Math.max(bigger, a[i]);
      if(i > 0 && a[i] != a[i - 1]){
        f = true;
      }
    }
    int t = 0;
    int k = 0;
    if(f){
      for(int i = 0; i < n; i++){
        if(a[i] == bigger){
          t++;
        }else{
          k++;
        }
      }
    }else{
      if(a[0] / (n - 1) == 2){
        t = n;
      }else{
        k = n;
      }
    }
    System.out.println(t + " " + k);
  }
}
0