結果

問題 No.135 とりあえず1次元の問題
ユーザー YOSHIYOSHI
提出日時 2021-03-01 21:43:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 288 ms / 5,000 ms
コード長 754 bytes
コンパイル時間 3,873 ms
コンパイル使用メモリ 84,392 KB
実行使用メモリ 61,136 KB
最終ジャッジ日時 2024-04-14 03:52:16
合計ジャッジ時間 7,781 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 279 ms
61,012 KB
testcase_01 AC 66 ms
51,264 KB
testcase_02 AC 66 ms
50,928 KB
testcase_03 AC 65 ms
51,040 KB
testcase_04 AC 68 ms
51,208 KB
testcase_05 AC 70 ms
50,684 KB
testcase_06 AC 68 ms
51,196 KB
testcase_07 AC 72 ms
50,864 KB
testcase_08 AC 67 ms
51,184 KB
testcase_09 AC 69 ms
51,088 KB
testcase_10 AC 68 ms
51,256 KB
testcase_11 AC 68 ms
50,820 KB
testcase_12 AC 87 ms
51,272 KB
testcase_13 AC 68 ms
51,020 KB
testcase_14 AC 86 ms
51,720 KB
testcase_15 AC 75 ms
51,268 KB
testcase_16 AC 84 ms
51,500 KB
testcase_17 AC 86 ms
51,700 KB
testcase_18 AC 73 ms
50,944 KB
testcase_19 AC 84 ms
51,680 KB
testcase_20 AC 75 ms
51,580 KB
testcase_21 AC 242 ms
60,916 KB
testcase_22 AC 288 ms
61,136 KB
evil01.txt AC 283 ms
61,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Stream;

public class No00000135_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int[] arr = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		Arrays.sort(arr);
		boolean first = true;
		int dis = 0;
		for(int i = 1; i < n; i++) {
			if(arr[i - 1] != arr[i]) {
				if(first) {
					first = false;
					dis = Math.abs(arr[i] - arr[i - 1]);
				}
				dis = Math.min(dis, Math.abs(arr[i] - arr[i - 1]));
			}
		}
		System.out.println(dis);
	}
}
0