結果

問題 No.135 とりあえず1次元の問題
ユーザー r.suzukir.suzuki
提出日時 2016-01-02 23:09:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 630 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 3,349 ms
コンパイル使用メモリ 72,632 KB
実行使用メモリ 61,176 KB
最終ジャッジ日時 2023-09-01 23:09:08
合計ジャッジ時間 10,509 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 588 ms
61,176 KB
testcase_01 AC 125 ms
55,968 KB
testcase_02 AC 128 ms
55,908 KB
testcase_03 AC 130 ms
55,668 KB
testcase_04 AC 138 ms
56,260 KB
testcase_05 AC 137 ms
56,044 KB
testcase_06 AC 137 ms
56,016 KB
testcase_07 AC 140 ms
55,516 KB
testcase_08 AC 137 ms
56,128 KB
testcase_09 AC 138 ms
55,732 KB
testcase_10 AC 140 ms
56,044 KB
testcase_11 AC 138 ms
55,920 KB
testcase_12 AC 159 ms
56,092 KB
testcase_13 AC 136 ms
55,728 KB
testcase_14 AC 191 ms
56,140 KB
testcase_15 AC 156 ms
56,008 KB
testcase_16 AC 193 ms
57,848 KB
testcase_17 AC 190 ms
56,276 KB
testcase_18 AC 141 ms
55,504 KB
testcase_19 AC 189 ms
56,052 KB
testcase_20 AC 185 ms
56,000 KB
testcase_21 AC 579 ms
60,888 KB
testcase_22 AC 630 ms
60,900 KB
evil01.txt AC 594 ms
61,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

public class No_166 {

	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int n = sc.nextInt();
		int[] X = new int[n];
		int distance = Integer.MAX_VALUE;

		for (int i = 0; i < n; i++) {
			X[i] = sc.nextInt();
		}

		java.util.Arrays.sort(X);

		for (int i = 0; i < X.length - 1; i++) {
			if (X[i] == X[i + 1]) {
				continue;
			}
			distance = Math.min(distance, Math.abs(X[i] - X[i + 1]));
		}

		if (distance != Integer.MAX_VALUE) {
			System.out.println(distance);
		} else {
			System.out.println(0);
		}
		sc.close();

	}

}
0