結果

問題 No.135 とりあえず1次元の問題
ユーザー rf141
提出日時 2015-08-10 03:56:18
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 4,251 ms
コンパイル使用メモリ 76,620 KB
実行使用メモリ 61,244 KB
最終ジャッジ日時 2025-01-03 07:19:53
合計ジャッジ時間 11,657 ms
ジャッジサーバーID
(参考情報)
judge1 / 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;
		for(int i = 1; i < n-1; i++){
			if(point[i]!=point[i+1]){
				if(point[i+1]-point[i] < min && point[i+1]-point[i] > 0){
					min = point[i+1]-point[i];
				}
			}
		}
		return (min==1000001)?0:min;
	}
}
0