結果

問題 No.135 とりあえず1次元の問題
ユーザー takeya_okino
提出日時 2017-06-25 12:13:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 670 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 74,620 KB
実行使用メモリ 59,544 KB
最終ジャッジ日時 2024-10-04 08:26:55
合計ジャッジ時間 9,574 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] x = new int[N];
    for(int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }
    Arrays.sort(x);
    int ans = Integer.MAX_VALUE;
    for(int i = 1; i < N; i++) {
      if(x[i] > x[i - 1]) ans = Math.min(ans, x[i] - x[i - 1]);
    }
    if(ans == Integer.MAX_VALUE) ans = 0;
    System.out.println(ans);
  }
}
0