結果

問題 No.135 とりあえず1次元の問題
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-25 12:13:00
言語 Java19
(openjdk 21)
結果
AC  
実行時間 628 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 2,406 ms
コンパイル使用メモリ 71,700 KB
実行使用メモリ 61,000 KB
最終ジャッジ日時 2023-07-27 13:17:55
合計ジャッジ時間 9,866 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 594 ms
60,708 KB
testcase_01 AC 127 ms
55,872 KB
testcase_02 AC 129 ms
55,604 KB
testcase_03 AC 128 ms
55,552 KB
testcase_04 AC 139 ms
55,556 KB
testcase_05 AC 139 ms
55,984 KB
testcase_06 AC 139 ms
55,576 KB
testcase_07 AC 141 ms
55,632 KB
testcase_08 AC 139 ms
55,844 KB
testcase_09 AC 141 ms
55,816 KB
testcase_10 AC 140 ms
55,600 KB
testcase_11 AC 140 ms
56,124 KB
testcase_12 AC 163 ms
56,216 KB
testcase_13 AC 140 ms
55,804 KB
testcase_14 AC 194 ms
56,636 KB
testcase_15 AC 159 ms
56,076 KB
testcase_16 AC 193 ms
56,004 KB
testcase_17 AC 194 ms
56,328 KB
testcase_18 AC 146 ms
55,796 KB
testcase_19 AC 194 ms
56,120 KB
testcase_20 AC 189 ms
56,060 KB
testcase_21 AC 556 ms
60,808 KB
testcase_22 AC 628 ms
61,000 KB
evil01.txt AC 602 ms
61,064 KB
権限があれば一括ダウンロードができます

ソースコード

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