結果

問題 No.112 ややこしい鶴亀算
ユーザー aim_cpoaim_cpo
提出日時 2019-04-19 14:56:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 174 ms / 5,000 ms
コード長 947 bytes
コンパイル時間 6,272 ms
コンパイル使用メモリ 76,652 KB
実行使用メモリ 58,448 KB
最終ジャッジ日時 2023-10-23 17:33:21
合計ジャッジ時間 10,464 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
58,156 KB
testcase_01 AC 144 ms
57,620 KB
testcase_02 AC 153 ms
58,276 KB
testcase_03 AC 153 ms
56,232 KB
testcase_04 AC 144 ms
57,284 KB
testcase_05 AC 144 ms
57,604 KB
testcase_06 AC 155 ms
58,148 KB
testcase_07 AC 156 ms
58,252 KB
testcase_08 AC 147 ms
57,620 KB
testcase_09 AC 148 ms
57,444 KB
testcase_10 AC 153 ms
58,308 KB
testcase_11 AC 156 ms
58,068 KB
testcase_12 AC 144 ms
57,796 KB
testcase_13 AC 145 ms
57,584 KB
testcase_14 AC 153 ms
57,676 KB
testcase_15 AC 159 ms
58,200 KB
testcase_16 AC 162 ms
58,256 KB
testcase_17 AC 161 ms
58,448 KB
testcase_18 AC 162 ms
58,380 KB
testcase_19 AC 151 ms
57,800 KB
testcase_20 AC 152 ms
57,500 KB
testcase_21 AC 160 ms
58,244 KB
testcase_22 AC 161 ms
58,212 KB
testcase_23 AC 174 ms
58,408 KB
testcase_24 AC 151 ms
57,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

import static java.lang.Math.max;
import static java.lang.Math.min;

public class TaskL {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int a[] = new int[n];
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; ++i) {
            a[i] = cin.nextInt();
            min = min(min, a[i]);
            max = max(max, a[i]);
        }
        if (max == min) {
            int one = max / (n - 1);
            if (one == 2) {
                System.out.println(n + " " + 0);
            } else {
                System.out.println(0 + " " + n);
            }
        } else {
            int t = 0, k = 0;
            for (int i = 0; i < n; ++i) {
                if (a[i] == min) k++;
                else t++;
            }
            System.out.println(t + " " + k);
        }
    }
}
0