結果

問題 No.135 とりあえず1次元の問題
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-12 07:59:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 532 ms / 5,000 ms
コード長 629 bytes
コンパイル時間 1,898 ms
コンパイル使用メモリ 71,888 KB
実行使用メモリ 60,916 KB
最終ジャッジ日時 2023-09-02 00:42:58
合計ジャッジ時間 8,388 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 532 ms
60,916 KB
testcase_01 AC 121 ms
56,172 KB
testcase_02 AC 122 ms
55,872 KB
testcase_03 AC 119 ms
55,824 KB
testcase_04 AC 127 ms
56,208 KB
testcase_05 AC 130 ms
55,820 KB
testcase_06 AC 129 ms
57,724 KB
testcase_07 AC 129 ms
55,876 KB
testcase_08 AC 130 ms
56,232 KB
testcase_09 AC 129 ms
55,880 KB
testcase_10 AC 129 ms
56,200 KB
testcase_11 AC 128 ms
55,868 KB
testcase_12 AC 142 ms
56,420 KB
testcase_13 AC 128 ms
56,096 KB
testcase_14 AC 175 ms
55,892 KB
testcase_15 AC 151 ms
55,884 KB
testcase_16 AC 179 ms
56,608 KB
testcase_17 AC 175 ms
56,636 KB
testcase_18 AC 130 ms
56,204 KB
testcase_19 AC 174 ms
57,008 KB
testcase_20 AC 169 ms
56,208 KB
testcase_21 AC 504 ms
60,652 KB
testcase_22 AC 530 ms
60,664 KB
evil01.txt AC 556 ms
60,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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