結果

問題 No.21 平均の差
ユーザー YOSHIYOSHI
提出日時 2021-02-17 13:19:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 603 bytes
コンパイル時間 3,346 ms
コンパイル使用メモリ 72,904 KB
実行使用メモリ 56,420 KB
最終ジャッジ日時 2023-10-12 00:24:35
合計ジャッジ時間 5,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,808 KB
testcase_01 AC 124 ms
55,892 KB
testcase_02 AC 123 ms
55,812 KB
testcase_03 AC 122 ms
56,420 KB
testcase_04 AC 122 ms
55,708 KB
testcase_05 AC 124 ms
55,828 KB
testcase_06 AC 123 ms
55,908 KB
testcase_07 AC 123 ms
56,196 KB
testcase_08 AC 120 ms
55,972 KB
testcase_09 AC 123 ms
55,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class No00000021_Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		scan.nextLine();

		scan.nextLine();
		List<Integer> arr = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			arr.add(Integer.parseInt(scan.nextLine()));
		}

		int max = arr.get(0);
		int min = arr.get(0);
		for(int num : arr) {
			if(max < num) {
				max = num;
			} else if(num < min) {
				min = num;
			}
		}

		System.out.println(max - min);

		scan.close();

	}

}
0