結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
![]() |
提出日時 | 2017-02-21 22:17:50 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 625 bytes |
コンパイル時間 | 2,314 ms |
コンパイル使用メモリ | 75,144 KB |
実行使用メモリ | 59,336 KB |
最終ジャッジ日時 | 2024-06-11 07:15:32 |
合計ジャッジ時間 | 10,000 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 1 |
ソースコード
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] x = new int[n]; for(int i=0; i<n; i++) { x[i] = in.nextInt(); } Arrays.sort(x); int len = Integer.MAX_VALUE; for(int i=1; i<n; i++) { if(x[i] != x[i-1]) { len = Math.min(len, Math.abs(x[i] - x[i-1])); } } System.out.println(len); in.close(); } }