結果

問題 No.406 鴨等間隔の法則
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-13 12:49:22
言語 Java19
(openjdk 21)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 582 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 71,972 KB
実行使用メモリ 63,068 KB
最終ジャッジ日時 2023-09-21 18:38:31
合計ジャッジ時間 17,669 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 437 ms
60,492 KB
testcase_01 AC 124 ms
55,688 KB
testcase_02 AC 123 ms
55,916 KB
testcase_03 AC 127 ms
56,268 KB
testcase_04 AC 605 ms
60,292 KB
testcase_05 AC 407 ms
60,356 KB
testcase_06 AC 414 ms
61,036 KB
testcase_07 AC 409 ms
60,548 KB
testcase_08 AC 570 ms
62,388 KB
testcase_09 AC 616 ms
60,960 KB
testcase_10 AC 436 ms
60,744 KB
testcase_11 AC 547 ms
60,384 KB
testcase_12 AC 490 ms
60,872 KB
testcase_13 AC 458 ms
60,628 KB
testcase_14 AC 553 ms
60,408 KB
testcase_15 AC 231 ms
57,720 KB
testcase_16 AC 243 ms
59,536 KB
testcase_17 AC 210 ms
58,272 KB
testcase_18 AC 249 ms
59,448 KB
testcase_19 AC 263 ms
61,232 KB
testcase_20 AC 276 ms
61,160 KB
testcase_21 AC 294 ms
60,984 KB
testcase_22 AC 350 ms
60,536 KB
testcase_23 AC 474 ms
60,372 KB
testcase_24 AC 549 ms
60,472 KB
testcase_25 AC 640 ms
61,296 KB
testcase_26 AC 597 ms
62,092 KB
testcase_27 AC 564 ms
60,632 KB
testcase_28 AC 555 ms
60,716 KB
testcase_29 AC 592 ms
61,556 KB
testcase_30 AC 600 ms
62,512 KB
testcase_31 AC 577 ms
63,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
		int[] x = new int[n];
		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		for(int i = 0 ; i < n - 1 ; i++) {
			if(x[i] == x[i + 1]) {
				System.out.println("NO");
				return;
			}
		}
		int sub = x[1] - x[0];
		for(int i =  1 ; i < n - 1 ; i++) {
			if(x[i + 1] - x[i] != sub) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}
0