結果

問題 No.135 とりあえず1次元の問題
ユーザー 37zigen37zigen
提出日時 2016-03-30 14:49:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 560 ms / 5,000 ms
コード長 634 bytes
コンパイル時間 4,372 ms
コンパイル使用メモリ 71,536 KB
実行使用メモリ 61,108 KB
最終ジャッジ日時 2023-09-02 00:22:01
合計ジャッジ時間 9,255 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 560 ms
60,900 KB
testcase_01 AC 118 ms
55,784 KB
testcase_02 AC 122 ms
55,696 KB
testcase_03 AC 119 ms
55,756 KB
testcase_04 AC 131 ms
55,784 KB
testcase_05 AC 130 ms
55,940 KB
testcase_06 AC 130 ms
55,568 KB
testcase_07 AC 130 ms
55,948 KB
testcase_08 AC 129 ms
56,656 KB
testcase_09 AC 129 ms
56,152 KB
testcase_10 AC 130 ms
56,132 KB
testcase_11 AC 128 ms
56,016 KB
testcase_12 AC 152 ms
55,784 KB
testcase_13 AC 128 ms
56,024 KB
testcase_14 AC 178 ms
56,240 KB
testcase_15 AC 146 ms
56,292 KB
testcase_16 AC 180 ms
56,384 KB
testcase_17 AC 177 ms
57,228 KB
testcase_18 AC 137 ms
55,544 KB
testcase_19 AC 175 ms
56,436 KB
testcase_20 AC 169 ms
56,672 KB
testcase_21 AC 507 ms
61,108 KB
testcase_22 AC 555 ms
60,768 KB
evil01.txt AC 563 ms
61,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder135;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
//		PriorityQueue<Integer> pq=new PriorityQueue(n);
		int[] pq=new int[n];
		for(int i=0;i<n;i++){
			pq[i]=sc.nextInt();
			}
		Arrays.sort(pq);
		int minInterbal=999999999;
		for(int i=0;i<n-1;i++){
			if(pq[i]==pq[i+1])continue;
			int interbal=Math.abs(pq[i]-pq[i+1]);
			minInterbal=Math.min(minInterbal, interbal);
		}
		if(minInterbal==999999999){
			System.out.println(0);
		}else{
			System.out.println(minInterbal);
		}
		
		
	}
}
0