結果

問題 No.135 とりあえず1次元の問題
ユーザー カニ戯(ryカニ戯(ry
提出日時 2015-05-15 02:41:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 607 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 72,284 KB
実行使用メモリ 61,540 KB
最終ジャッジ日時 2023-09-01 03:35:59
合計ジャッジ時間 8,988 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 573 ms
61,540 KB
testcase_01 AC 122 ms
56,048 KB
testcase_02 AC 122 ms
56,100 KB
testcase_03 AC 124 ms
55,920 KB
testcase_04 AC 134 ms
56,052 KB
testcase_05 AC 131 ms
56,092 KB
testcase_06 AC 133 ms
56,116 KB
testcase_07 AC 136 ms
55,868 KB
testcase_08 AC 132 ms
55,936 KB
testcase_09 AC 139 ms
56,252 KB
testcase_10 AC 132 ms
56,032 KB
testcase_11 AC 135 ms
56,520 KB
testcase_12 AC 156 ms
56,180 KB
testcase_13 AC 132 ms
58,308 KB
testcase_14 AC 174 ms
54,536 KB
testcase_15 AC 156 ms
55,984 KB
testcase_16 AC 182 ms
56,512 KB
testcase_17 AC 183 ms
56,300 KB
testcase_18 AC 134 ms
56,108 KB
testcase_19 AC 179 ms
56,504 KB
testcase_20 AC 178 ms
56,192 KB
testcase_21 AC 559 ms
60,692 KB
testcase_22 AC 607 ms
60,888 KB
evil01.txt AC 589 ms
61,400 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;)m=((d=Math.abs(X[i]-X[++i]))>0&&d<m)?d:m;
        System.out.println(m==Integer.MAX_VALUE?0:m);
    }
}
0