結果

問題 No.112 ややこしい鶴亀算
ユーザー yagi2yagi2
提出日時 2017-04-25 11:35:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 992 bytes
コンパイル時間 2,071 ms
コンパイル使用メモリ 76,852 KB
実行使用メモリ 58,552 KB
最終ジャッジ日時 2023-10-11 09:19:06
合計ジャッジ時間 6,264 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
56,320 KB
testcase_01 AC 129 ms
56,456 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 133 ms
55,764 KB
testcase_05 AC 126 ms
56,228 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 125 ms
56,088 KB
testcase_09 AC 129 ms
55,828 KB
testcase_10 WA -
testcase_11 AC 124 ms
55,704 KB
testcase_12 WA -
testcase_13 AC 129 ms
56,256 KB
testcase_14 AC 133 ms
56,096 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 133 ms
56,816 KB
testcase_20 AC 133 ms
55,628 KB
testcase_21 WA -
testcase_22 AC 124 ms
56,116 KB
testcase_23 WA -
testcase_24 AC 134 ms
56,212 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) K++;
                if (A.get(i) == min) T++;
            }
            System.out.printf("%d %d\n", T, K);
        } else {
            System.out.println(((max / (A.size() - 1)) == 2)? (A.size() + " 0") : ("0 " + A.size()));
        }
    }
}
0