結果

問題 No.135 とりあえず1次元の問題
ユーザー spaciaspacia
提出日時 2015-12-23 14:11:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 72,216 KB
実行使用メモリ 61,360 KB
最終ジャッジ日時 2023-09-01 23:00:06
合計ジャッジ時間 5,439 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 241 ms
61,360 KB
testcase_01 AC 45 ms
49,400 KB
testcase_02 AC 44 ms
49,380 KB
testcase_03 WA -
testcase_04 AC 45 ms
49,448 KB
testcase_05 AC 44 ms
49,284 KB
testcase_06 AC 47 ms
47,208 KB
testcase_07 AC 45 ms
49,452 KB
testcase_08 AC 44 ms
49,572 KB
testcase_09 AC 45 ms
49,496 KB
testcase_10 AC 44 ms
49,440 KB
testcase_11 AC 44 ms
49,264 KB
testcase_12 AC 48 ms
49,376 KB
testcase_13 AC 45 ms
49,260 KB
testcase_14 AC 51 ms
49,264 KB
testcase_15 AC 47 ms
49,248 KB
testcase_16 AC 52 ms
47,400 KB
testcase_17 AC 52 ms
47,740 KB
testcase_18 AC 45 ms
49,240 KB
testcase_19 AC 51 ms
49,560 KB
testcase_20 AC 48 ms
49,612 KB
testcase_21 AC 218 ms
60,564 KB
testcase_22 AC 245 ms
61,344 KB
evil01.txt AC 257 ms
60,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main135 {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		String[] line = br.readLine().split(" ");
		int[] nums = new int[n];
		for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(line[i]);
		
		int ans = Integer.MAX_VALUE;
		Arrays.sort(nums);
		for (int i = 1; i < n; i++) {
			int sub = nums[i] - nums[i - 1];
			if (sub != 0 && sub < ans) ans = sub;
		}
		
		out(n == 1 ? 0 : ans);
		
	}
}
0