結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-31 22:43:08 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 856 ms / 5,000 ms |
| コード長 | 725 bytes |
| コンパイル時間 | 3,627 ms |
| コンパイル使用メモリ | 75,752 KB |
| 実行使用メモリ | 57,704 KB |
| 最終ジャッジ日時 | 2024-11-22 11:14:57 |
| 合計ジャッジ時間 | 12,136 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class No135 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int count = s.nextInt();
int[] pos = new int[count];
for (int i = 0; i < count; i++) {
pos[i] = s.nextInt();
}
pos = Arrays.stream(pos).distinct().sorted().toArray();
if (pos.length < 2) {
System.out.println(0);
return;
}
int min = Integer.MAX_VALUE;
for (int i = 1; i < pos.length; i++) {
int tmp = pos[i] - pos[i - 1];
if (min > tmp) {
min = tmp;
}
}
System.out.println(min);
}
}