結果

問題 No.135 とりあえず1次元の問題
ユーザー カニ戯(ryカニ戯(ry
提出日時 2015-02-24 16:25:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 562 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 71,824 KB
実行使用メモリ 61,140 KB
最終ジャッジ日時 2023-09-01 02:57:07
合計ジャッジ時間 8,595 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 561 ms
60,896 KB
testcase_01 AC 119 ms
55,928 KB
testcase_02 AC 120 ms
55,876 KB
testcase_03 AC 117 ms
56,000 KB
testcase_04 AC 127 ms
55,984 KB
testcase_05 AC 128 ms
56,400 KB
testcase_06 AC 128 ms
56,228 KB
testcase_07 AC 129 ms
56,532 KB
testcase_08 AC 127 ms
55,764 KB
testcase_09 AC 127 ms
55,884 KB
testcase_10 AC 131 ms
56,472 KB
testcase_11 AC 130 ms
56,564 KB
testcase_12 AC 155 ms
55,820 KB
testcase_13 AC 126 ms
56,016 KB
testcase_14 AC 176 ms
56,004 KB
testcase_15 AC 142 ms
56,252 KB
testcase_16 AC 167 ms
56,472 KB
testcase_17 AC 176 ms
56,240 KB
testcase_18 AC 130 ms
56,460 KB
testcase_19 AC 171 ms
56,248 KB
testcase_20 AC 168 ms
56,280 KB
testcase_21 AC 527 ms
61,140 KB
testcase_22 AC 562 ms
61,060 KB
evil01.txt AC 559 ms
60,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] a) {
		Scanner s = new Scanner(System.in);
		int N=s.nextInt(),i=0,d,m=Integer.MAX_VALUE;
		int[] X=new int[N];
		for(;i<N;)X[i++]=s.nextInt();
		Arrays.sort(X);
		for(i=0;i<N-1;){
			d=Math.abs(X[i]-X[++i]);
			m=(d>0&&d<m)?d:m;
		}
		System.out.println(m==Integer.MAX_VALUE?0:m);
	}
}
0