結果

問題 No.135 とりあえず1次元の問題
ユーザー YatsukuYatsuku
提出日時 2015-12-12 00:52:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 778 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 72,312 KB
実行使用メモリ 63,268 KB
最終ジャッジ日時 2023-09-01 22:56:26
合計ジャッジ時間 9,139 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 593 ms
62,172 KB
testcase_01 AC 128 ms
55,680 KB
testcase_02 WA -
testcase_03 AC 125 ms
55,688 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 136 ms
55,876 KB
testcase_11 AC 136 ms
55,996 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
evil01.txt AC 578 ms
60,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

class No_135 {
	public static void main(String args[]) {

		Scanner stdIn = new Scanner(System.in);		

		int num = stdIn.nextInt();

		int x_axis[] = new int[num];

		for (int i = 0; i < num; i++) {
			x_axis[i]	= stdIn.nextInt();
		}

		Arrays.sort(x_axis);

		int min = -1;
		int tmp = 0;
		boolean flag = false;
		for (int j = 0; j <= num - 2; j++) {
			if ( x_axis[j] == x_axis[j+1]) { continue; }
			if ( ! flag ) {
				min = Math.abs(x_axis[j] - x_axis[j+1]);	
				flag = true;
			} else {
				tmp = Math.abs(x_axis[j] - x_axis[j+1]);	
			}
			if (tmp <= min && min != -1) {
				min = tmp;
			} else {
				min = tmp;
		  }
		}
		if ( ! flag ) {
			System.out.println(0);
		} else {
			System.out.println(min);
		}

	}
}
0