結果

問題 No.135 とりあえず1次元の問題
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-20 15:54:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 565 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 71,468 KB
実行使用メモリ 60,816 KB
最終ジャッジ日時 2023-08-13 15:04:03
合計ジャッジ時間 8,955 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 556 ms
60,736 KB
testcase_01 AC 117 ms
55,956 KB
testcase_02 AC 117 ms
55,660 KB
testcase_03 AC 118 ms
56,612 KB
testcase_04 AC 127 ms
56,264 KB
testcase_05 AC 128 ms
56,128 KB
testcase_06 AC 127 ms
54,240 KB
testcase_07 AC 127 ms
55,444 KB
testcase_08 AC 129 ms
56,224 KB
testcase_09 AC 131 ms
55,452 KB
testcase_10 AC 130 ms
55,768 KB
testcase_11 AC 133 ms
56,276 KB
testcase_12 AC 148 ms
56,220 KB
testcase_13 AC 131 ms
55,616 KB
testcase_14 AC 178 ms
57,132 KB
testcase_15 AC 146 ms
55,844 KB
testcase_16 AC 166 ms
54,832 KB
testcase_17 AC 176 ms
56,044 KB
testcase_18 AC 138 ms
56,068 KB
testcase_19 AC 178 ms
56,284 KB
testcase_20 AC 167 ms
55,976 KB
testcase_21 AC 518 ms
60,712 KB
testcase_22 AC 565 ms
60,816 KB
evil01.txt AC 592 ms
61,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
		int[] x = new int[n];
		int ans = 1001001001;
		for(int i = 0 ; i < n ; i++) x[i] = sc.nextInt();
		Arrays.sort(x);
		for(int i = 0 ; i < n - 1 ; i++) {
			if(Math.abs(x[i + 1] - x[i]) >= 1) {
				ans = Math.min(ans, Math.abs(x[i + 1] - x[i]));
			}
		}
		if(ans == 0 || ans == 1001001001) {
			System.out.println(0);
		} else {
			System.out.println(ans);
		}
 	}
}

0