結果
| 問題 | No.135 とりあえず1次元の問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-14 04:16:12 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,569 bytes |
| 記録 | |
| コンパイル時間 | 3,942 ms |
| コンパイル使用メモリ | 82,472 KB |
| 実行使用メモリ | 103,272 KB |
| 最終ジャッジ日時 | 2026-03-03 22:09:43 |
| 合計ジャッジ時間 | 36,631 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 15 WA * 3 TLE * 4 |
ソースコード
import java.util.*;
public class Run {
public static void main (String arg[]) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int[] X = new int[N];
for (int i = 0; i < N; i++) {
X[i] = scan.nextInt();
}
heapSort(N, X);
int min = X[1] - X[0];
int tmp;
for (int i = 1; i < N-1; i++) {
tmp = X[i+1] - X[i];
if ((min==0 && tmp!=0) || min > tmp) min = tmp;
}
System.out.println(min);
}
public static void heapSort (int leaf, int[] A) {
int l = leaf;
int tmp;
for (int j = 0; j < l; j++) {
int root = leaf/2-1;
for (int i = root; i >= 0; i--) {
while ((root + 1) * 2 <= leaf) {
if ((root + 1) * 2 == leaf) {
tmp = (root + 1) * 2 - 1;
} else {
if (A[(root + 1) * 2 - 1] < A[(root + 1) * 2]) tmp = (root + 1) * 2;
else tmp = (root + 1) * 2 - 1;
}
if (A[root] < A[tmp]) {
swap(A, root, tmp);
root = tmp;
} else break;
}
root = i - 1;
}
tmp = A[0];
A[0] = A[leaf-1];
A[leaf-1] = tmp;
leaf--;
}
}
public static void swap (int[] A, int a, int b){
int tmp;
tmp = A[a];
A[a] = A[b];
A[b] = tmp;
}
}