結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2018-01-18 22:44:51 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 280 ms / 5,000 ms |
コード長 | 845 bytes |
コンパイル時間 | 3,665 ms |
コンパイル使用メモリ | 78,420 KB |
実行使用メモリ | 49,268 KB |
最終ジャッジ日時 | 2024-12-24 07:47:00 |
合計ジャッジ時間 | 7,229 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
package me.yukicoder.lv1; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class No0135 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { int N = Integer.parseInt(br.readLine()); String[] str = br.readLine().split(" "); int[] x = new int[N]; int min = 0; int tmp = 0; boolean boo = false; for (int i = 0; i < N; i++) { x[i] = Integer.parseInt(str[i]); } Arrays.sort(x); for (int i = 0; i < N - 1; i++) { int abs = Math.abs(x[i] - x[i + 1]); if (abs != 0) { if (!boo) { boo = true; min = abs; } min = Math.min(min, abs); } } System.out.println(min); } catch (IOException e) { e.printStackTrace(); } } }