結果

問題 No.135 とりあえず1次元の問題
ユーザー tsunatama5tsunatama5
提出日時 2015-09-20 23:50:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 470 ms / 5,000 ms
コード長 1,094 bytes
コンパイル時間 3,296 ms
コンパイル使用メモリ 74,800 KB
実行使用メモリ 69,712 KB
最終ジャッジ日時 2023-09-01 21:38:43
合計ジャッジ時間 9,398 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 469 ms
66,660 KB
testcase_01 AC 116 ms
55,952 KB
testcase_02 AC 117 ms
55,604 KB
testcase_03 AC 119 ms
56,076 KB
testcase_04 AC 121 ms
56,072 KB
testcase_05 AC 121 ms
55,632 KB
testcase_06 AC 123 ms
55,988 KB
testcase_07 AC 122 ms
55,900 KB
testcase_08 AC 121 ms
55,728 KB
testcase_09 AC 120 ms
55,852 KB
testcase_10 AC 122 ms
55,800 KB
testcase_11 AC 123 ms
55,900 KB
testcase_12 AC 136 ms
55,884 KB
testcase_13 AC 122 ms
55,924 KB
testcase_14 AC 148 ms
55,764 KB
testcase_15 AC 134 ms
55,980 KB
testcase_16 AC 160 ms
55,816 KB
testcase_17 AC 160 ms
56,028 KB
testcase_18 AC 125 ms
55,776 KB
testcase_19 AC 152 ms
56,180 KB
testcase_20 AC 136 ms
56,080 KB
testcase_21 AC 414 ms
69,712 KB
testcase_22 AC 470 ms
67,192 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;
		}
/*		
		for (i=0;i<=max;i++) {
			for (j=i;j<=max;j++) {
				temp = Math.abs(lint[i]-lint[j]);
				if (ans > temp && lint[i] != lint[j]) {
					ans = temp;
					System.out.printf("%d %d %d %d %d\n",i,lint[i],j,lint[j],temp);
				}
			}
		}
*/
		System.out.println(ans);
	}
}

0