結果

問題 No.135 とりあえず1次元の問題
ユーザー kohaku_kohaku
提出日時 2016-11-12 07:55:28
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 2,494 ms
コンパイル使用メモリ 80,572 KB
実行使用メモリ 49,052 KB
最終ジャッジ日時 2024-06-11 07:06:49
合計ジャッジ時間 9,842 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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];
        int sum = 0;
        for(int i=0; i<N; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        Arrays.sort(X);
        int min = sum;
        for(int i=1; i<N; i++){
            int temp = X[i]-X[i-1];
            if(temp!=0 && min>=temp){
                min = temp;
            }
        }
        if( min!=sum ){
            System.out.println(min);
        }else{
            System.out.println(0);
        }
    }
}
0