結果

問題 No.135 とりあえず1次元の問題
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-14 14:08:50
言語 Java19
(openjdk 21)
結果
AC  
実行時間 607 ms / 5,000 ms
コード長 513 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 71,332 KB
実行使用メモリ 61,288 KB
最終ジャッジ日時 2023-10-11 12:37:01
合計ジャッジ時間 9,308 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 595 ms
61,288 KB
testcase_01 AC 123 ms
56,028 KB
testcase_02 AC 124 ms
56,112 KB
testcase_03 AC 122 ms
56,232 KB
testcase_04 AC 134 ms
56,180 KB
testcase_05 AC 132 ms
56,008 KB
testcase_06 AC 134 ms
55,588 KB
testcase_07 AC 134 ms
55,580 KB
testcase_08 AC 136 ms
56,012 KB
testcase_09 AC 134 ms
56,000 KB
testcase_10 AC 135 ms
55,892 KB
testcase_11 AC 132 ms
56,288 KB
testcase_12 AC 150 ms
55,712 KB
testcase_13 AC 133 ms
55,916 KB
testcase_14 AC 182 ms
56,012 KB
testcase_15 AC 153 ms
56,580 KB
testcase_16 AC 187 ms
56,304 KB
testcase_17 AC 185 ms
56,512 KB
testcase_18 AC 141 ms
56,036 KB
testcase_19 AC 183 ms
56,532 KB
testcase_20 AC 170 ms
56,312 KB
testcase_21 AC 555 ms
60,896 KB
testcase_22 AC 607 ms
60,676 KB
evil01.txt AC 582 ms
62,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		if (n == 1) {
			System.out.println(0); return;
		}
		else {
			int[] ar = new int[n];
			for (int i=0; i<n; i++) ar[i] = sc.nextInt();
			Arrays.sort(ar);
			int min = Integer.MAX_VALUE;
			for (int i=1; i<n; i++) {
				if (ar[i]-ar[i-1] != 0) {
					min = Math.min(min, ar[i]-ar[i-1]);
				}
			}
			System.out.println(min==Integer.MAX_VALUE?0:min);
		}
		
	}
}
0