結果

問題 No.135 とりあえず1次元の問題
ユーザー mits58mits58
提出日時 2016-05-05 15:19:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 608 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 71,888 KB
実行使用メモリ 61,460 KB
最終ジャッジ日時 2023-09-02 00:24:58
合計ジャッジ時間 9,000 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 593 ms
60,864 KB
testcase_01 AC 126 ms
55,968 KB
testcase_02 AC 126 ms
56,104 KB
testcase_03 AC 124 ms
55,888 KB
testcase_04 AC 135 ms
55,900 KB
testcase_05 AC 137 ms
56,224 KB
testcase_06 AC 135 ms
56,128 KB
testcase_07 AC 135 ms
55,836 KB
testcase_08 AC 138 ms
56,244 KB
testcase_09 AC 134 ms
55,876 KB
testcase_10 AC 135 ms
55,880 KB
testcase_11 AC 138 ms
55,800 KB
testcase_12 AC 156 ms
55,896 KB
testcase_13 AC 135 ms
56,500 KB
testcase_14 AC 190 ms
56,224 KB
testcase_15 AC 154 ms
56,296 KB
testcase_16 AC 192 ms
58,384 KB
testcase_17 AC 189 ms
55,964 KB
testcase_18 AC 141 ms
56,068 KB
testcase_19 AC 186 ms
56,060 KB
testcase_20 AC 178 ms
56,024 KB
testcase_21 AC 585 ms
61,460 KB
testcase_22 AC 608 ms
60,768 KB
evil01.txt AC 582 ms
61,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
        	int n=sc.nextInt();
        	int[] x=new int[n];
        	for(int i=0;i<n;i++) x[i]=sc.nextInt();
        	Arrays.sort(x);
        	int res=Integer.MAX_VALUE/2;
        	for(int i=1;i<n;i++){
        		if(x[i]==x[i-1]) continue;
        		res=Math.min(res, x[i]-x[i-1]);
        	}
        	if(res==Integer.MAX_VALUE/2) System.out.println(0);
        	else System.out.println(res);
        }
    }
}
0