結果

問題 No.135 とりあえず1次元の問題
ユーザー uafr_csuafr_cs
提出日時 2015-05-15 13:20:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 860 ms / 5,000 ms
コード長 671 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 73,696 KB
実行使用メモリ 69,024 KB
最終ジャッジ日時 2023-09-01 03:36:22
合計ジャッジ時間 9,652 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 860 ms
68,900 KB
testcase_01 AC 124 ms
56,524 KB
testcase_02 AC 125 ms
55,900 KB
testcase_03 AC 125 ms
55,816 KB
testcase_04 AC 133 ms
56,148 KB
testcase_05 AC 132 ms
55,812 KB
testcase_06 AC 133 ms
56,176 KB
testcase_07 AC 132 ms
55,868 KB
testcase_08 AC 132 ms
55,596 KB
testcase_09 AC 131 ms
56,720 KB
testcase_10 AC 131 ms
55,572 KB
testcase_11 AC 129 ms
56,024 KB
testcase_12 AC 159 ms
56,076 KB
testcase_13 AC 133 ms
56,576 KB
testcase_14 AC 181 ms
56,552 KB
testcase_15 AC 159 ms
56,244 KB
testcase_16 AC 187 ms
57,108 KB
testcase_17 AC 183 ms
56,276 KB
testcase_18 AC 136 ms
55,860 KB
testcase_19 AC 184 ms
55,816 KB
testcase_20 AC 180 ms
56,556 KB
testcase_21 AC 544 ms
60,352 KB
testcase_22 AC 779 ms
69,024 KB
evil01.txt AC 658 ms
67,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		TreeSet<Integer> set = new TreeSet<Integer>();
		for(int i = 0; i < N; i++){
			set.add(sc.nextInt());
		}
		ArrayList<Integer> list = new ArrayList<Integer>(set);
		
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < list.size() - 1; i++){
			min = Math.min(min, Math.abs(list.get(i) - list.get(i + 1)));
		}
		if(min == Integer.MAX_VALUE){
			min = 0;
		}
		
		System.out.println(min);
		
	}
}
0