結果

問題 No.21 平均の差
ユーザー dazydazy
提出日時 2016-09-06 16:22:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 3,370 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 56,044 KB
最終ジャッジ日時 2023-08-09 22:28:39
合計ジャッジ時間 5,449 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,492 KB
testcase_01 AC 122 ms
55,740 KB
testcase_02 AC 122 ms
55,720 KB
testcase_03 AC 123 ms
55,884 KB
testcase_04 AC 121 ms
55,680 KB
testcase_05 AC 122 ms
56,044 KB
testcase_06 AC 120 ms
55,660 KB
testcase_07 AC 122 ms
55,628 KB
testcase_08 AC 122 ms
55,536 KB
testcase_09 AC 120 ms
55,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        if (N < 3||N > 9||K < 3||K > N) System.exit(1);
        int[] n = new int[N];
        int max = 0, min = 1001;
        for (int i = 0; i < N; i++) {
            n[i] = scan.nextInt();
            if (n[i] < 1||n[i] > 1000) System.exit(1);
            if (max < n[i]) max = n[i];
            if (min > n[i]) min = n[i];
        }

        System.out.println(max - min);
    }
}
0