結果

問題 No.21 平均の差
ユーザー masuyuumasuyuu
提出日時 2020-10-20 21:03:11
言語 Java19
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 461 bytes
コンパイル時間 2,817 ms
コンパイル使用メモリ 71,828 KB
実行使用メモリ 55,756 KB
最終ジャッジ日時 2023-09-28 13:48:35
合計ジャッジ時間 4,876 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,452 KB
testcase_01 AC 126 ms
55,700 KB
testcase_02 AC 126 ms
55,752 KB
testcase_03 AC 123 ms
55,732 KB
testcase_04 AC 126 ms
55,560 KB
testcase_05 AC 125 ms
55,652 KB
testcase_06 AC 124 ms
55,396 KB
testcase_07 AC 121 ms
55,296 KB
testcase_08 AC 123 ms
55,756 KB
testcase_09 AC 123 ms
55,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int g = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}

		for(int i=0;i<n;i++) {
			for(int j=a.length-1;j>0+i;j--) {
				if(a[j]>a[j-1]) {
					int temp = a[j];
					a[j] = a[j-1];
					a[j-1] = temp;
				}
			}
		}
		System.out.println(a[0]-a[a.length-1]);

	}
}
0