結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 571 ms
61,072 KB
testcase_01 AC 123 ms
55,788 KB
testcase_02 AC 124 ms
55,752 KB
testcase_03 WA -
testcase_04 AC 135 ms
55,748 KB
testcase_05 AC 133 ms
56,036 KB
testcase_06 AC 133 ms
56,240 KB
testcase_07 AC 132 ms
53,764 KB
testcase_08 AC 135 ms
56,164 KB
testcase_09 AC 134 ms
56,048 KB
testcase_10 AC 134 ms
58,220 KB
testcase_11 AC 134 ms
55,928 KB
testcase_12 AC 150 ms
56,324 KB
testcase_13 AC 133 ms
56,264 KB
testcase_14 AC 183 ms
56,148 KB
testcase_15 AC 152 ms
55,560 KB
testcase_16 AC 183 ms
56,232 KB
testcase_17 AC 181 ms
56,300 KB
testcase_18 AC 139 ms
55,928 KB
testcase_19 AC 181 ms
57,204 KB
testcase_20 AC 177 ms
56,152 KB
testcase_21 AC 550 ms
60,712 KB
testcase_22 AC 567 ms
60,936 KB
evil01.txt AC 563 ms
61,452 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;
		if(min==0)min+=1;
		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