結果

問題 No.112 ややこしい鶴亀算
ユーザー yagi2yagi2
提出日時 2017-04-25 11:37:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 992 bytes
コンパイル時間 2,473 ms
コンパイル使用メモリ 76,780 KB
実行使用メモリ 56,556 KB
最終ジャッジ日時 2023-10-11 09:20:20
合計ジャッジ時間 6,411 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
56,096 KB
testcase_01 AC 123 ms
56,300 KB
testcase_02 AC 107 ms
54,076 KB
testcase_03 AC 108 ms
56,240 KB
testcase_04 AC 129 ms
55,980 KB
testcase_05 AC 126 ms
56,140 KB
testcase_06 AC 109 ms
56,232 KB
testcase_07 AC 113 ms
56,556 KB
testcase_08 AC 123 ms
56,320 KB
testcase_09 AC 121 ms
54,076 KB
testcase_10 AC 109 ms
56,268 KB
testcase_11 AC 106 ms
55,972 KB
testcase_12 AC 108 ms
56,364 KB
testcase_13 AC 120 ms
56,148 KB
testcase_14 AC 127 ms
56,112 KB
testcase_15 AC 111 ms
56,100 KB
testcase_16 AC 113 ms
56,368 KB
testcase_17 AC 114 ms
55,820 KB
testcase_18 AC 114 ms
56,308 KB
testcase_19 AC 130 ms
56,432 KB
testcase_20 AC 126 ms
56,388 KB
testcase_21 AC 112 ms
56,068 KB
testcase_22 AC 116 ms
55,480 KB
testcase_23 AC 114 ms
56,240 KB
testcase_24 AC 128 ms
56,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        List<Integer> A = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            A.add(Integer.parseInt(sc.next()));
        }

        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            if (max < A.get(i)) max = A.get(i);
            if (min > A.get(i)) min = A.get(i);
        }

        if (max != min) {
            int K = 0;
            int T = 0;
            for (int i = 0; i < N; i++) {
                if (A.get(i) == max) T++;
                if (A.get(i) == min) K++;
            }
            System.out.printf("%d %d\n", T, K);
        } else {
            System.out.println(((max / (A.size() - 1)) == 2)? (A.size() + " 0") : ("0 " + A.size()));
        }
    }
}
0