結果

問題 No.135 とりあえず1次元の問題
ユーザー rf141rf141
提出日時 2015-08-10 03:56:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 3,784 ms
コンパイル使用メモリ 73,252 KB
実行使用メモリ 60,988 KB
最終ジャッジ日時 2023-09-01 21:27:07
合計ジャッジ時間 10,930 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 577 ms
60,972 KB
testcase_01 AC 123 ms
55,644 KB
testcase_02 AC 124 ms
55,852 KB
testcase_03 AC 125 ms
55,880 KB
testcase_04 AC 133 ms
55,648 KB
testcase_05 AC 129 ms
55,892 KB
testcase_06 AC 133 ms
56,284 KB
testcase_07 AC 130 ms
56,232 KB
testcase_08 AC 131 ms
55,848 KB
testcase_09 AC 133 ms
56,044 KB
testcase_10 AC 133 ms
56,068 KB
testcase_11 AC 133 ms
55,884 KB
testcase_12 AC 153 ms
56,120 KB
testcase_13 AC 135 ms
56,044 KB
testcase_14 AC 184 ms
56,532 KB
testcase_15 AC 163 ms
56,284 KB
testcase_16 AC 184 ms
56,144 KB
testcase_17 AC 186 ms
56,288 KB
testcase_18 AC 142 ms
55,676 KB
testcase_19 AC 187 ms
56,184 KB
testcase_20 AC 180 ms
56,496 KB
testcase_21 WA -
testcase_22 AC 611 ms
60,988 KB
evil01.txt AC 587 ms
60,804 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 = 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