結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 575 ms
61,656 KB
testcase_01 AC 127 ms
55,820 KB
testcase_02 AC 125 ms
55,996 KB
testcase_03 AC 126 ms
56,144 KB
testcase_04 AC 133 ms
56,148 KB
testcase_05 AC 135 ms
56,000 KB
testcase_06 AC 137 ms
56,036 KB
testcase_07 AC 135 ms
56,056 KB
testcase_08 AC 135 ms
55,964 KB
testcase_09 AC 136 ms
56,028 KB
testcase_10 AC 133 ms
56,080 KB
testcase_11 AC 135 ms
55,836 KB
testcase_12 AC 154 ms
55,752 KB
testcase_13 AC 134 ms
55,584 KB
testcase_14 AC 180 ms
56,328 KB
testcase_15 AC 156 ms
56,176 KB
testcase_16 AC 188 ms
54,364 KB
testcase_17 AC 190 ms
55,832 KB
testcase_18 AC 144 ms
55,744 KB
testcase_19 AC 184 ms
56,484 KB
testcase_20 AC 184 ms
56,468 KB
testcase_21 AC 555 ms
60,544 KB
testcase_22 AC 626 ms
61,096 KB
evil01.txt AC 596 ms
61,176 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;i++){
int e = X[i] - X[i+1];
if (e < 0) e *= -1;
if (e != 0 && e < m) {
m = e;
}
        }
        System.out.println(m==Integer.MAX_VALUE?0:m);
    }
}
0