結果

問題 No.135 とりあえず1次元の問題
ユーザー TwinkleStar74
提出日時 2017-10-10 00:50:59
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 930 bytes
コンパイル時間 3,771 ms
コンパイル使用メモリ 82,492 KB
実行使用メモリ 53,268 KB
最終ジャッジ日時 2024-11-17 07:12:51
合計ジャッジ時間 7,156 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class No135{
	public static void main(String[] args) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String n = br.readLine();
			String[] str = br.readLine().split(" ");
			for(int i=0; i < str.length; i++)
				list.add(Integer.parseInt(str[i]));
			Collections.sort(list);
			System.out.println(getAns(list));
		}
		catch(IOException e){
			e.getStackTrace();
		}
		catch(NumberFormatException e){
			e.getStackTrace();
		}
	}
	
	public static int getAns(ArrayList<Integer> a){
		int ans = 100000000;
		for(int i= 2; i< a.size(); i++){
			if(a.get(i) == a.get(i-1))  continue;
			else if(ans > (a.get(i) - a.get(i-1)))  ans = a.get(i) - a.get(i-1);
		}
		return ans;
	}
}
0