結果

問題 No.135 とりあえず1次元の問題
ユーザー rf141
提出日時 2015-08-10 03:58:46
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 3,905 ms
コンパイル使用メモリ 76,900 KB
実行使用メモリ 49,640 KB
最終ジャッジ日時 2025-01-03 07:22:00
合計ジャッジ時間 10,721 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class liner{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n==1){
			System.out.println(0);
			return;
		}
		int[] point = new int[n];
		for(int i = 0; i < n; i++){
			point[i] = scan.nextInt();
		}
		Arrays.sort(point);
		System.out.println(result(point,n));
	}
	public static int result(int[] point,int n){
		int min = 1000001;
		int x=0;
		for(int i = 1; i < n-1; i++){
			if(point[i]!=point[i+1]){
				x = Math.abs(point[i]-point[i+1]);
				min = Math.min(x,min);
			}
		}
		return (min==1000001)?0:min;
	}
}
0