結果

問題 No.135 とりあえず1次元の問題
ユーザー ぴろずぴろず
提出日時 2015-01-25 23:32:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 735 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 2,389 ms
コンパイル使用メモリ 72,160 KB
実行使用メモリ 66,148 KB
最終ジャッジ日時 2023-08-31 01:24:34
合計ジャッジ時間 9,670 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 693 ms
66,148 KB
testcase_01 AC 123 ms
55,684 KB
testcase_02 AC 123 ms
55,956 KB
testcase_03 AC 122 ms
56,052 KB
testcase_04 AC 132 ms
55,824 KB
testcase_05 AC 135 ms
55,964 KB
testcase_06 AC 133 ms
55,956 KB
testcase_07 AC 134 ms
55,988 KB
testcase_08 AC 135 ms
55,876 KB
testcase_09 AC 133 ms
56,348 KB
testcase_10 AC 133 ms
56,072 KB
testcase_11 AC 136 ms
55,808 KB
testcase_12 AC 158 ms
55,920 KB
testcase_13 AC 135 ms
56,404 KB
testcase_14 AC 188 ms
56,020 KB
testcase_15 AC 154 ms
55,944 KB
testcase_16 AC 189 ms
56,320 KB
testcase_17 AC 180 ms
56,160 KB
testcase_18 AC 141 ms
56,224 KB
testcase_19 AC 179 ms
55,844 KB
testcase_20 AC 185 ms
56,744 KB
testcase_21 AC 578 ms
61,212 KB
testcase_22 AC 735 ms
66,136 KB
evil01.txt AC 637 ms
63,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no135;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n == 0) {
			System.out.println(0);
			return;
		}
		Integer[] x = new Integer[n];
		for(int i=0;i<n;i++) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		if (x[0] == x[n-1]) {
			System.out.println(0);
			return;
		}
		int ans = 1 << 29;
		for(int i=0;i<n-1;i++) {
			if (x[i+1] - x[i] > 0) {
				ans = Math.min(ans, x[i+1] - x[i]);
			}
		}
		System.out.println(ans);
	}

}
0