結果

問題 No.135 とりあえず1次元の問題
ユーザー yagi2yagi2
提出日時 2017-04-24 19:04:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 78,716 KB
実行使用メモリ 64,028 KB
最終ジャッジ日時 2023-10-11 13:19:27
合計ジャッジ時間 8,773 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 449 ms
62,808 KB
testcase_01 AC 116 ms
56,092 KB
testcase_02 AC 117 ms
55,508 KB
testcase_03 AC 117 ms
55,724 KB
testcase_04 WA -
testcase_05 AC 125 ms
55,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 170 ms
56,260 KB
testcase_20 WA -
testcase_21 AC 542 ms
64,028 KB
testcase_22 AC 510 ms
63,688 KB
evil01.txt AC 540 ms
63,400 KB
権限があれば一括ダウンロードができます

ソースコード

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