結果

問題 No.135 とりあえず1次元の問題
ユーザー rf141rf141
提出日時 2015-08-10 03:48:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 3,153 ms
コンパイル使用メモリ 72,356 KB
実行使用メモリ 61,928 KB
最終ジャッジ日時 2023-09-01 21:25:23
合計ジャッジ時間 10,282 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 549 ms
61,928 KB
testcase_01 AC 124 ms
56,064 KB
testcase_02 AC 124 ms
53,872 KB
testcase_03 WA -
testcase_04 AC 135 ms
55,840 KB
testcase_05 AC 133 ms
55,848 KB
testcase_06 AC 136 ms
55,860 KB
testcase_07 AC 132 ms
55,840 KB
testcase_08 AC 132 ms
56,156 KB
testcase_09 AC 133 ms
55,876 KB
testcase_10 AC 133 ms
55,664 KB
testcase_11 AC 131 ms
56,116 KB
testcase_12 AC 149 ms
55,628 KB
testcase_13 AC 133 ms
55,504 KB
testcase_14 AC 182 ms
56,156 KB
testcase_15 AC 152 ms
56,000 KB
testcase_16 AC 183 ms
56,036 KB
testcase_17 AC 181 ms
56,484 KB
testcase_18 AC 140 ms
56,080 KB
testcase_19 AC 169 ms
56,608 KB
testcase_20 AC 178 ms
55,892 KB
testcase_21 WA -
testcase_22 AC 566 ms
60,412 KB
evil01.txt AC 566 ms
61,180 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 100001;
		if(n==2)return min;
		for(int i = 0; i < n-1; i++){
			if(point[i+1]-point[i] < min && point[i+1]-point[i] > 0){
				min = point[i+1]-point[i];
			}
		}
		return min;
	}
}
0