結果

問題 No.21 平均の差
ユーザー uafr_cs
提出日時 2015-05-10 16:59:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 517 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 73,840 KB
実行使用メモリ 40,932 KB
最終ジャッジ日時 2024-07-05 21:27:30
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int K = sc.nextInt();
		
		int[] arr = new int[N];
		for(int i = 0; i < N; i++){
			arr[i] = sc.nextInt();
		}
		
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++){
			max = Math.max(max, arr[i]);
			min = Math.min(min, arr[i]);
		}
		
		System.out.println(max - min);
		
		
	}
	
}
0