結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー キョウチク
提出日時 2019-09-20 03:44:11
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 854 bytes
コンパイル時間 3,554 ms
コンパイル使用メモリ 77,800 KB
実行使用メモリ 60,528 KB
最終ジャッジ日時 2024-09-13 11:12:48
合計ジャッジ時間 15,858 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test{
    public static void main(String[] args) throws IOException{
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(buf.readLine());
        String[] s = buf.readLine().split(" ");
        int X[] = new int[N];
        X[0]=Integer.parseInt(s[0]);
        for(int i=1;i<N;i++) {
        	X[i]=Integer.parseInt(s[i]);
        	for(int j=i;j>0;j--) {
        		if(X[j-1]>X[j]) {
        			int temp=X[j];
        			X[j]=X[j-1];
        			X[j-1]=temp;
        		}
        	}
        }
        int min=1000000;
        for(int i=1;i<N;i++) {
        	if(Math.abs(X[i-1]-X[i])<min) {
        		min=Math.abs(X[i-1]-X[i]);
        	}
        }
        System.out.println(min);
    }
}
0