結果

問題 No.135 とりあえず1次元の問題
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-25 12:13:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 648 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 75,324 KB
実行使用メモリ 48,612 KB
最終ジャッジ日時 2024-04-15 01:18:46
合計ジャッジ時間 9,084 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 598 ms
48,612 KB
testcase_01 AC 111 ms
40,352 KB
testcase_02 AC 106 ms
40,256 KB
testcase_03 AC 123 ms
41,344 KB
testcase_04 AC 129 ms
41,660 KB
testcase_05 AC 138 ms
41,688 KB
testcase_06 AC 131 ms
41,588 KB
testcase_07 AC 139 ms
41,496 KB
testcase_08 AC 134 ms
41,132 KB
testcase_09 AC 133 ms
41,376 KB
testcase_10 AC 134 ms
41,308 KB
testcase_11 AC 125 ms
41,536 KB
testcase_12 AC 144 ms
41,776 KB
testcase_13 AC 132 ms
41,684 KB
testcase_14 AC 176 ms
42,280 KB
testcase_15 AC 160 ms
41,488 KB
testcase_16 AC 183 ms
42,288 KB
testcase_17 AC 183 ms
42,528 KB
testcase_18 AC 143 ms
41,436 KB
testcase_19 AC 176 ms
42,424 KB
testcase_20 AC 171 ms
42,128 KB
testcase_21 AC 529 ms
48,472 KB
testcase_22 AC 648 ms
48,536 KB
evil01.txt AC 618 ms
49,212 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