結果

問題 No.135 とりあえず1次元の問題
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 19:47:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 75,100 KB
実行使用メモリ 53,960 KB
最終ジャッジ日時 2024-04-16 22:22:02
合計ジャッジ時間 9,453 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 666 ms
48,756 KB
testcase_01 AC 132 ms
41,588 KB
testcase_02 AC 130 ms
41,228 KB
testcase_03 WA -
testcase_04 AC 144 ms
41,736 KB
testcase_05 AC 143 ms
41,736 KB
testcase_06 AC 143 ms
42,048 KB
testcase_07 AC 143 ms
41,536 KB
testcase_08 AC 142 ms
41,800 KB
testcase_09 AC 144 ms
41,960 KB
testcase_10 AC 144 ms
41,548 KB
testcase_11 AC 144 ms
41,680 KB
testcase_12 AC 173 ms
41,768 KB
testcase_13 AC 143 ms
41,512 KB
testcase_14 AC 182 ms
42,304 KB
testcase_15 AC 160 ms
41,888 KB
testcase_16 AC 183 ms
42,384 KB
testcase_17 AC 181 ms
42,332 KB
testcase_18 AC 136 ms
41,792 KB
testcase_19 AC 174 ms
42,320 KB
testcase_20 AC 173 ms
42,288 KB
testcase_21 AC 556 ms
48,464 KB
testcase_22 AC 694 ms
48,544 KB
evil01.txt AC 670 ms
48,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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