結果

問題 No.21 平均の差
ユーザー masuyuu
提出日時 2020-10-20 21:03:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 461 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 73,880 KB
実行使用メモリ 41,284 KB
最終ジャッジ日時 2024-07-21 08:28:57
合計ジャッジ時間 3,638 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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