結果

問題 No.135 とりあえず1次元の問題
ユーザー omi_UTomi_UT
提出日時 2017-03-10 21:22:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 508 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 71,680 KB
実行使用メモリ 60,756 KB
最終ジャッジ日時 2023-09-06 13:19:33
合計ジャッジ時間 8,718 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 507 ms
60,100 KB
testcase_01 AC 115 ms
55,416 KB
testcase_02 AC 116 ms
55,772 KB
testcase_03 AC 118 ms
55,852 KB
testcase_04 AC 126 ms
57,504 KB
testcase_05 AC 125 ms
57,744 KB
testcase_06 AC 121 ms
57,872 KB
testcase_07 AC 127 ms
57,496 KB
testcase_08 AC 125 ms
57,936 KB
testcase_09 AC 133 ms
57,960 KB
testcase_10 AC 134 ms
57,960 KB
testcase_11 AC 131 ms
57,836 KB
testcase_12 AC 146 ms
58,208 KB
testcase_13 AC 137 ms
55,904 KB
testcase_14 AC 181 ms
58,740 KB
testcase_15 AC 145 ms
57,896 KB
testcase_16 AC 190 ms
60,392 KB
testcase_17 AC 180 ms
58,476 KB
testcase_18 AC 134 ms
57,816 KB
testcase_19 AC 184 ms
58,304 KB
testcase_20 AC 181 ms
58,212 KB
testcase_21 AC 508 ms
60,440 KB
testcase_22 AC 486 ms
60,756 KB
evil01.txt AC 547 ms
62,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] x = new boolean[1000001];

		for (int i=0;i<n;i++){
			x[sc.nextInt()] = true;
		}

		int maxi = 1000001;

		for (int i=0;i<1000000;i++){
			if(x[i]){
				for(int j=i+1;j<Math.min(1000001,i+maxi);j++){
					if(x[j]){
						maxi = j-i;
					}
				}
			}
		}

		if(maxi == 1000001){ maxi = 0; }
		System.out.println(maxi);
	}
}
0