結果

問題 No.135 とりあえず1次元の問題
ユーザー rf141rf141
提出日時 2015-08-10 04:00:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 603 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 3,284 ms
コンパイル使用メモリ 73,448 KB
実行使用メモリ 61,028 KB
最終ジャッジ日時 2023-09-01 21:30:14
合計ジャッジ時間 10,305 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 593 ms
61,028 KB
testcase_01 AC 126 ms
56,080 KB
testcase_02 AC 124 ms
56,064 KB
testcase_03 AC 127 ms
56,264 KB
testcase_04 AC 137 ms
56,264 KB
testcase_05 AC 135 ms
55,772 KB
testcase_06 AC 134 ms
55,820 KB
testcase_07 AC 136 ms
55,628 KB
testcase_08 AC 134 ms
56,284 KB
testcase_09 AC 134 ms
56,020 KB
testcase_10 AC 134 ms
56,180 KB
testcase_11 AC 134 ms
56,072 KB
testcase_12 AC 156 ms
56,276 KB
testcase_13 AC 136 ms
55,892 KB
testcase_14 AC 183 ms
56,160 KB
testcase_15 AC 155 ms
56,408 KB
testcase_16 AC 187 ms
56,804 KB
testcase_17 AC 187 ms
56,228 KB
testcase_18 AC 142 ms
55,920 KB
testcase_19 AC 186 ms
56,472 KB
testcase_20 AC 184 ms
56,136 KB
testcase_21 AC 560 ms
60,956 KB
testcase_22 AC 603 ms
60,536 KB
evil01.txt AC 585 ms
61,396 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 = 0; 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