結果

問題 No.135 とりあえず1次元の問題
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-20 15:49:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 74,808 KB
実行使用メモリ 59,652 KB
最終ジャッジ日時 2024-05-01 07:55:43
合計ジャッジ時間 8,286 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 622 ms
59,552 KB
testcase_01 AC 130 ms
54,012 KB
testcase_02 AC 127 ms
54,028 KB
testcase_03 AC 116 ms
54,160 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 118 ms
53,992 KB
testcase_11 AC 113 ms
54,016 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 489 ms
58,884 KB
testcase_22 WA -
evil01.txt AC 538 ms
59,376 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.abs(x[i + 1] - x[i]);
			}
		}
		if(ans == 0 || ans == 1001001001) {
			System.out.println(0);
		} else {
			System.out.println(ans);
		}
 	}
}

0