結果

問題 No.135 とりあえず1次元の問題
ユーザー tsunatama5tsunatama5
提出日時 2015-09-21 00:26:18
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,110 bytes
コンパイル時間 3,184 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 76,420 KB
最終ジャッジ日時 2023-09-01 21:39:20
合計ジャッジ時間 15,830 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
evil01.txt -- -
権限があれば一括ダウンロードができます

ソースコード

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 = 0;
		int temp = 0;
		int ans = 1000000;
		int max = 0;
		int min = 1000000;
		
//		Arrays.sort(lint);
		
		for (i=0; i<lint.length-1; i++) {
		    for (j=lint.length-1; j>i; j--) {
		        if (lint[j-1] > lint[j] ) {
		            temp = lint[j-1];
		            lint[j-1] = lint[j];
		            lint[j] = temp;
		        }
		    }
		}

		temp = 0;
		
		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