結果

問題 No.21 平均の差
ユーザー eagleeagle
提出日時 2022-06-15 14:40:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 506 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 74,748 KB
実行使用メモリ 54,512 KB
最終ジャッジ日時 2024-04-14 23:17:15
合計ジャッジ時間 4,239 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,240 KB
testcase_01 AC 137 ms
54,280 KB
testcase_02 AC 133 ms
54,360 KB
testcase_03 AC 131 ms
54,444 KB
testcase_04 AC 133 ms
54,276 KB
testcase_05 AC 135 ms
54,512 KB
testcase_06 AC 134 ms
54,028 KB
testcase_07 AC 132 ms
54,200 KB
testcase_08 AC 133 ms
54,184 KB
testcase_09 AC 135 ms
54,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数字の数
		int N = sc.nextInt();
		int K = sc.nextInt();
		//振り分けた際のグループの個数
		int[] num = new int[N];
		for(int i = 0; i < N; i++) {
			num[i] = sc.nextInt();
		}
		Arrays.sort(num);
		int min = num[0];
		int max = num[num.length - 1];
		int ans = max - min;
		System.out.println(ans);
	}
}
0