結果

問題 No.21 平均の差
ユーザー koukonkokoukonko
提出日時 2015-12-07 12:26:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 796 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 71,952 KB
実行使用メモリ 49,828 KB
最終ジャッジ日時 2023-10-12 19:55:45
合計ジャッジ時間 2,866 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,828 KB
testcase_01 AC 43 ms
49,264 KB
testcase_02 AC 41 ms
49,352 KB
testcase_03 AC 43 ms
49,432 KB
testcase_04 AC 43 ms
49,336 KB
testcase_05 AC 43 ms
49,444 KB
testcase_06 AC 43 ms
49,256 KB
testcase_07 AC 43 ms
49,148 KB
testcase_08 AC 43 ms
49,484 KB
testcase_09 AC 42 ms
49,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		try{
			int N = Integer.parseInt(buff.readLine());
			int K = Integer.parseInt(buff.readLine());
			int[] box = new int[N];
			for(int i = 0; i < N; ++i){
				box[i] = Integer.parseInt(buff.readLine());
				for(int j = 0; j < i; ++j){
					if(box[i] < box[j]){
						int w = box[i];
						box[i] = box[j];
						box[j] = w;
					}
				}
			}

			int posiMin = 0, posiMax = N -1;
			int max = box[posiMax], min = box[posiMin];

			int ans =  max - min;
			System.out.println(ans);


		} catch (NumberFormatException e) {

		} catch (IOException e) {

		}
	}
}
0