結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 586 ms
60,880 KB
testcase_01 AC 124 ms
55,464 KB
testcase_02 WA -
testcase_03 AC 125 ms
55,964 KB
testcase_04 AC 136 ms
56,040 KB
testcase_05 AC 138 ms
55,964 KB
testcase_06 AC 137 ms
55,860 KB
testcase_07 AC 137 ms
55,932 KB
testcase_08 AC 136 ms
55,680 KB
testcase_09 AC 141 ms
55,844 KB
testcase_10 AC 137 ms
56,052 KB
testcase_11 AC 135 ms
55,776 KB
testcase_12 AC 154 ms
56,308 KB
testcase_13 AC 137 ms
55,824 KB
testcase_14 AC 180 ms
56,312 KB
testcase_15 AC 154 ms
56,280 KB
testcase_16 AC 188 ms
56,108 KB
testcase_17 AC 184 ms
55,916 KB
testcase_18 AC 141 ms
55,924 KB
testcase_19 AC 187 ms
56,032 KB
testcase_20 AC 180 ms
56,068 KB
testcase_21 AC 556 ms
62,580 KB
testcase_22 AC 590 ms
61,240 KB
evil01.txt AC 573 ms
60,424 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 = point[1]-point[0];
		if(n==2)return min;
		for(int i = 1; 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