結果

問題 No.135 とりあえず1次元の問題
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-20 15:54:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 610 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 1,889 ms
コンパイル使用メモリ 74,608 KB
実行使用メモリ 59,828 KB
最終ジャッジ日時 2024-05-01 07:55:53
合計ジャッジ時間 7,987 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 610 ms
59,828 KB
testcase_01 AC 97 ms
52,544 KB
testcase_02 AC 108 ms
52,860 KB
testcase_03 AC 99 ms
52,464 KB
testcase_04 AC 125 ms
56,140 KB
testcase_05 AC 121 ms
54,152 KB
testcase_06 AC 118 ms
53,280 KB
testcase_07 AC 126 ms
54,120 KB
testcase_08 AC 118 ms
54,048 KB
testcase_09 AC 117 ms
54,128 KB
testcase_10 AC 121 ms
54,140 KB
testcase_11 AC 120 ms
54,188 KB
testcase_12 AC 145 ms
54,584 KB
testcase_13 AC 131 ms
54,296 KB
testcase_14 AC 165 ms
54,600 KB
testcase_15 AC 150 ms
54,416 KB
testcase_16 AC 162 ms
54,396 KB
testcase_17 AC 170 ms
54,228 KB
testcase_18 AC 126 ms
54,112 KB
testcase_19 AC 162 ms
54,324 KB
testcase_20 AC 155 ms
54,268 KB
testcase_21 AC 491 ms
59,176 KB
testcase_22 AC 496 ms
59,532 KB
evil01.txt AC 574 ms
59,504 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