結果

問題 No.135 とりあえず1次元の問題
ユーザー yagi2
提出日時 2017-04-24 19:04:09
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 2,988 ms
コンパイル使用メモリ 77,196 KB
実行使用メモリ 51,768 KB
最終ジャッジ日時 2024-09-13 12:04:39
合計ジャッジ時間 8,920 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            p.add(Integer.parseInt(sc.next()));
        }

        int d = Integer.MAX_VALUE;
        for(int i = 0; i < N - 1; i++) {
            if (Math.abs(p.get(i) - p.get(i+1)) == 0) continue;
            if (d > Math.abs(p.get(i) - p.get(i+1))) d = Math.abs(p.get(i) - p.get(i+1));
        }
        System.out.println((d == Integer.MAX_VALUE)? "0" : d);
    }
}
0