結果

問題 No.135 とりあえず1次元の問題
ユーザー tsunatama5tsunatama5
提出日時 2015-02-04 20:14:44
言語 Java19
(openjdk 21)
結果
AC  
実行時間 482 ms / 5,000 ms
コード長 852 bytes
コンパイル時間 3,284 ms
コンパイル使用メモリ 74,656 KB
実行使用メモリ 69,988 KB
最終ジャッジ日時 2023-09-01 02:54:50
合計ジャッジ時間 9,487 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 476 ms
66,836 KB
testcase_01 AC 117 ms
55,788 KB
testcase_02 AC 116 ms
56,216 KB
testcase_03 AC 122 ms
55,948 KB
testcase_04 AC 122 ms
56,084 KB
testcase_05 AC 122 ms
55,928 KB
testcase_06 AC 120 ms
56,156 KB
testcase_07 AC 124 ms
56,272 KB
testcase_08 AC 119 ms
56,020 KB
testcase_09 AC 116 ms
56,020 KB
testcase_10 AC 120 ms
56,184 KB
testcase_11 AC 121 ms
56,076 KB
testcase_12 AC 134 ms
56,552 KB
testcase_13 AC 120 ms
56,020 KB
testcase_14 AC 161 ms
55,956 KB
testcase_15 AC 136 ms
55,692 KB
testcase_16 AC 150 ms
56,376 KB
testcase_17 AC 157 ms
56,680 KB
testcase_18 AC 122 ms
56,440 KB
testcase_19 AC 158 ms
54,444 KB
testcase_20 AC 132 ms
56,664 KB
testcase_21 AC 425 ms
69,988 KB
testcase_22 AC 482 ms
66,756 KB
evil01.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package P135;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class P135 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		int nint = Integer.parseInt(n);
		String l = sc.nextLine();
		String[] lstrs = l.split(" ");

		int lint[] = new int[nint];
		int i = 0;
		int cmax = nint - 1;
		
		for (i=0;i<=cmax;i++) {
			lint[i] = Integer.parseInt(lstrs[i]);
		}
		
		int j;
		int temp = 0;
		int ans = 1000000;
		int max = 0;
		int min = 1000000;
		
		Arrays.sort(lint);
		
		for (i=1;i<=cmax;i++) {
			temp = Math.abs(lint[i-1] - lint[i]);
			if (ans > temp && lint[i] != lint[i-1]) {
				ans = temp;
			}
			if (max < temp){
				max = temp;
			}
			if (min > temp) {
				min = temp;
			}
		}
		if (max == min) {
			ans = 0;
		}
		System.out.println(ans);
	}
}

0