結果

問題 No.135 とりあえず1次元の問題
ユーザー shinwisteriashinwisteria
提出日時 2018-03-04 11:46:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 873 ms / 5,000 ms
コード長 647 bytes
コンパイル時間 3,881 ms
コンパイル使用メモリ 73,688 KB
実行使用メモリ 68,900 KB
最終ジャッジ日時 2023-09-21 09:44:54
合計ジャッジ時間 12,302 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 873 ms
68,900 KB
testcase_01 AC 126 ms
56,112 KB
testcase_02 AC 124 ms
55,496 KB
testcase_03 AC 126 ms
56,000 KB
testcase_04 AC 139 ms
55,732 KB
testcase_05 AC 138 ms
55,688 KB
testcase_06 AC 141 ms
56,096 KB
testcase_07 AC 140 ms
55,720 KB
testcase_08 AC 139 ms
56,112 KB
testcase_09 AC 141 ms
55,820 KB
testcase_10 AC 137 ms
55,872 KB
testcase_11 AC 139 ms
55,600 KB
testcase_12 AC 160 ms
55,740 KB
testcase_13 AC 140 ms
56,112 KB
testcase_14 AC 199 ms
57,288 KB
testcase_15 AC 161 ms
55,784 KB
testcase_16 AC 200 ms
56,900 KB
testcase_17 AC 191 ms
57,072 KB
testcase_18 AC 144 ms
56,564 KB
testcase_19 AC 199 ms
57,164 KB
testcase_20 AC 196 ms
56,012 KB
testcase_21 AC 567 ms
60,732 KB
testcase_22 AC 860 ms
68,892 KB
evil01.txt AC 744 ms
68,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package m.shin;
import java.util.Scanner;
import java.util.TreeSet;
public class Con135 {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		TreeSet<Integer> x = new TreeSet<>();
		for(int i = 0;i < N;i++){
			x.add(s.nextInt());
		}
		s.close();

		int from = x.pollFirst() , to = 0;
		if(x.size() == 0){
			System.out.println("0");
		}else{
			int dmin = Math.abs(x.last() - from) , size = x.size();
			for(int i = 0;i < size;i++){
				to = x.pollFirst();
				if(dmin > Math.abs(to - from)){
					dmin = Math.abs(to - from);
				}
				from = to;
			}
			System.out.println(dmin);
		}
	}

}
0