結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
fkwnw3_1243
|
| 提出日時 | 2017-04-29 17:22:12 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 268 ms / 5,000 ms |
| コード長 | 1,029 bytes |
| コンパイル時間 | 4,201 ms |
| コンパイル使用メモリ | 75,240 KB |
| 実行使用メモリ | 60,744 KB |
| 最終ジャッジ日時 | 2024-09-13 22:55:39 |
| 合計ジャッジ時間 | 5,360 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import static java.lang.System.in;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
int N = Integer.parseInt(reader.readLine());
String[] inputs = reader.readLine().split(" ");
long[] points = new long[N];
for (int i = 0; i < N; i++) {
points[i] = Long.parseLong(inputs[i]);
}
Arrays.sort(points);
long minDistance = Long.MAX_VALUE;
boolean found = false;
for (int i = 1; i < N; i++) {
if(points[i] != points[i-1] ) {
found = true;
minDistance = Math.min(minDistance, Math.abs(points[i] - points[i-1]));
}
}
if (found) {
System.out.println(minDistance);
} else {
System.out.println(0);
}
}
}
fkwnw3_1243