結果

問題 No.21 平均の差
ユーザー uafr_csuafr_cs
提出日時 2015-05-10 16:59:07
言語 Java19
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 517 bytes
コンパイル時間 4,271 ms
コンパイル使用メモリ 71,320 KB
実行使用メモリ 55,900 KB
最終ジャッジ日時 2023-09-19 09:44:49
合計ジャッジ時間 5,313 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,672 KB
testcase_01 AC 132 ms
55,732 KB
testcase_02 AC 132 ms
55,424 KB
testcase_03 AC 131 ms
55,632 KB
testcase_04 AC 132 ms
55,336 KB
testcase_05 AC 130 ms
55,900 KB
testcase_06 AC 130 ms
55,732 KB
testcase_07 AC 128 ms
55,572 KB
testcase_08 AC 132 ms
55,560 KB
testcase_09 AC 131 ms
55,636 KB
権限があれば一括ダウンロードができます

ソースコード

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