結果

問題 No.135 とりあえず1次元の問題
ユーザー nCk_cvnCk_cv
提出日時 2016-01-21 02:10:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 602 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 4,680 ms
コンパイル使用メモリ 72,308 KB
実行使用メモリ 61,048 KB
最終ジャッジ日時 2023-09-01 23:17:12
合計ジャッジ時間 11,164 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 602 ms
60,940 KB
testcase_01 AC 127 ms
55,848 KB
testcase_02 AC 128 ms
55,708 KB
testcase_03 AC 129 ms
55,580 KB
testcase_04 AC 139 ms
56,040 KB
testcase_05 AC 137 ms
56,148 KB
testcase_06 AC 138 ms
55,948 KB
testcase_07 AC 139 ms
55,764 KB
testcase_08 AC 138 ms
55,836 KB
testcase_09 AC 136 ms
55,916 KB
testcase_10 AC 140 ms
56,052 KB
testcase_11 AC 139 ms
56,124 KB
testcase_12 AC 157 ms
56,432 KB
testcase_13 AC 146 ms
56,068 KB
testcase_14 AC 194 ms
54,824 KB
testcase_15 AC 161 ms
56,116 KB
testcase_16 AC 193 ms
56,272 KB
testcase_17 AC 191 ms
55,776 KB
testcase_18 AC 142 ms
55,656 KB
testcase_19 AC 177 ms
57,260 KB
testcase_20 AC 188 ms
56,232 KB
testcase_21 AC 550 ms
61,048 KB
testcase_22 AC 576 ms
58,888 KB
evil01.txt AC 582 ms
61,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		if(N == 1) System.out.println("0");
		int MIN = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i = 0; i < N-1; i++) {
			if(x[i] == x[i+1]) continue;
			MIN = Math.min(MIN, (int)Math.abs(x[i] - x[i+1]));
		}
		if(MIN == Integer.MAX_VALUE) MIN = 0;
		System.out.println(MIN);
	}
}
0