結果

問題 No.112 ややこしい鶴亀算
ユーザー aim_cpo
提出日時 2019-04-19 14:56:52
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 947 bytes
コンパイル時間 5,414 ms
コンパイル使用メモリ 77,128 KB
実行使用メモリ 55,284 KB
最終ジャッジ日時 2024-09-22 11:29:09
合計ジャッジ時間 9,009 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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