結果

問題 No.135 とりあえず1次元の問題
ユーザー jimanojimano
提出日時 2018-01-18 22:53:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 909 bytes
コンパイル時間 3,180 ms
コンパイル使用メモリ 71,992 KB
実行使用メモリ 60,752 KB
最終ジャッジ日時 2023-08-25 21:25:38
合計ジャッジ時間 6,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 207 ms
60,612 KB
testcase_01 AC 42 ms
49,328 KB
testcase_02 AC 43 ms
49,376 KB
testcase_03 AC 42 ms
49,296 KB
testcase_04 WA -
testcase_05 AC 43 ms
49,404 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 49 ms
49,408 KB
testcase_20 WA -
testcase_21 AC 201 ms
60,484 KB
testcase_22 AC 196 ms
60,752 KB
evil01.txt AC 208 ms
60,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class No0135 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int N = Integer.parseInt(br.readLine());
			String[] str = br.readLine().split(" ");
			int[] x = new int[N];
			int min = 0;// Integer.MAX_VALUEとかにして状態を持つようにしてやるとよい?
			int tmp = 0;
			boolean boo = false;

			for (int i = 0; i < N; i++) {
				x[i] = Integer.parseInt(str[i]);
			}

			for (int i = 0; i < N - 1; i++) {
				int abs = Math.abs(x[i] - x[i + 1]);
				if (abs != 0) {
					if (!boo) {
						boo = true;
						min = abs;
					}
					min = Math.min(min, abs);
				}
			}
			System.out.println(min);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
0