結果

問題 No.21 平均の差
ユーザー eagleeagle
提出日時 2022-06-15 14:40:14
言語 Java
(openjdk 23)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 506 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-10-04 04:23:50
合計ジャッジ時間 4,079 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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