結果

問題 No.21 平均の差
ユーザー aikon_marimoaikon_marimo
提出日時 2018-05-02 20:58:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 466 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 72,008 KB
実行使用メモリ 56,152 KB
最終ジャッジ日時 2023-09-10 08:55:34
合計ジャッジ時間 3,929 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,800 KB
testcase_01 AC 118 ms
55,956 KB
testcase_02 AC 120 ms
56,152 KB
testcase_03 AC 123 ms
55,720 KB
testcase_04 AC 123 ms
55,504 KB
testcase_05 AC 119 ms
55,836 KB
testcase_06 AC 121 ms
55,952 KB
testcase_07 AC 124 ms
55,908 KB
testcase_08 AC 120 ms
55,792 KB
testcase_09 AC 128 ms
55,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int k = in.nextInt();

		int min = in.nextInt();
		int max = in.nextInt();
		if (max < min) {
			int t = max;
			max = min;
			min = t;
		}
		for (int i = 0; i < N - 2; i++) {
			int val = in.nextInt();
			if (max < val)
				max = val;
			if (min > val)
				min = val;
		}
		System.out.println(max - min);
	}
}
0