結果

問題 No.406 鴨等間隔の法則
ユーザー YamaKasaYamaKasa
提出日時 2018-05-04 23:14:08
言語 Java19
(openjdk 21)
結果
AC  
実行時間 635 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 3,248 ms
コンパイル使用メモリ 72,128 KB
実行使用メモリ 62,844 KB
最終ジャッジ日時 2023-09-21 18:48:57
合計ジャッジ時間 19,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 434 ms
60,476 KB
testcase_01 AC 124 ms
55,904 KB
testcase_02 AC 122 ms
55,664 KB
testcase_03 AC 124 ms
56,028 KB
testcase_04 AC 609 ms
60,204 KB
testcase_05 AC 409 ms
60,548 KB
testcase_06 AC 432 ms
60,512 KB
testcase_07 AC 421 ms
60,616 KB
testcase_08 AC 574 ms
60,268 KB
testcase_09 AC 635 ms
61,736 KB
testcase_10 AC 436 ms
60,440 KB
testcase_11 AC 541 ms
60,328 KB
testcase_12 AC 474 ms
60,316 KB
testcase_13 AC 460 ms
60,052 KB
testcase_14 AC 568 ms
60,588 KB
testcase_15 AC 229 ms
59,908 KB
testcase_16 AC 249 ms
59,200 KB
testcase_17 AC 210 ms
58,652 KB
testcase_18 AC 247 ms
59,532 KB
testcase_19 AC 260 ms
60,324 KB
testcase_20 AC 290 ms
61,060 KB
testcase_21 AC 297 ms
60,356 KB
testcase_22 AC 354 ms
60,420 KB
testcase_23 AC 480 ms
60,344 KB
testcase_24 AC 522 ms
60,344 KB
testcase_25 AC 628 ms
61,240 KB
testcase_26 AC 615 ms
61,040 KB
testcase_27 AC 578 ms
60,780 KB
testcase_28 AC 557 ms
60,608 KB
testcase_29 AC 606 ms
61,548 KB
testcase_30 AC 611 ms
62,844 KB
testcase_31 AC 594 ms
60,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []x = new int[N];
		for(int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}
		scan.close();
		Arrays.sort(x);
		int k = x[1] - x[0];
		if(k == 0) {
			System.out.println("NO");
			System.exit(0);
		}
		for(int i = 1; i < N - 1; i++) {
			if(k != x[i+1] - x[i]) {
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");

	}
}
0