結果

問題 No.135 とりあえず1次元の問題
ユーザー k_kadorak_kadora
提出日時 2015-06-11 01:02:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 3,283 ms
コンパイル使用メモリ 72,816 KB
実行使用メモリ 61,392 KB
最終ジャッジ日時 2023-09-01 03:41:19
合計ジャッジ時間 9,688 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 555 ms
61,332 KB
testcase_01 AC 119 ms
55,888 KB
testcase_02 AC 119 ms
56,364 KB
testcase_03 WA -
testcase_04 AC 126 ms
55,880 KB
testcase_05 AC 127 ms
55,932 KB
testcase_06 AC 125 ms
55,884 KB
testcase_07 AC 129 ms
56,060 KB
testcase_08 AC 127 ms
56,112 KB
testcase_09 AC 128 ms
56,032 KB
testcase_10 AC 125 ms
55,868 KB
testcase_11 AC 127 ms
56,056 KB
testcase_12 AC 133 ms
55,780 KB
testcase_13 AC 126 ms
56,564 KB
testcase_14 AC 170 ms
56,708 KB
testcase_15 AC 135 ms
54,904 KB
testcase_16 AC 169 ms
56,240 KB
testcase_17 AC 169 ms
56,524 KB
testcase_18 AC 126 ms
56,036 KB
testcase_19 AC 167 ms
56,936 KB
testcase_20 AC 167 ms
56,416 KB
testcase_21 AC 445 ms
60,760 KB
testcase_22 AC 454 ms
61,392 KB
evil01.txt AC 545 ms
61,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;
public class Dim1{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int n,res=100001;
		n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i<n;i++){
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		if(a.length>1){
			if(a[0] != a[1])res = Math.abs(a[0] - a[1]);
			for(int i =0;i<n-1;i++){
				if(a[i] != a[i+1]){
					if(Math.abs(a[i] - a[i+1]) < res)res = Math.abs(a[i] - a[i+1]);
				}
			}
		}else{
			res = 0;
		}
		System.out.println(res);
	}
}
0