結果

問題 No.406 鴨等間隔の法則
ユーザー YukimotoPGYukimotoPG
提出日時 2019-02-13 18:05:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 606 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 3,935 ms
コンパイル使用メモリ 72,904 KB
実行使用メモリ 62,544 KB
最終ジャッジ日時 2023-09-21 18:58:17
合計ジャッジ時間 18,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 423 ms
60,804 KB
testcase_01 AC 119 ms
56,104 KB
testcase_02 AC 119 ms
55,988 KB
testcase_03 AC 121 ms
55,968 KB
testcase_04 AC 584 ms
62,544 KB
testcase_05 AC 402 ms
60,408 KB
testcase_06 AC 414 ms
60,800 KB
testcase_07 AC 414 ms
60,956 KB
testcase_08 AC 556 ms
61,016 KB
testcase_09 AC 599 ms
61,644 KB
testcase_10 AC 427 ms
60,508 KB
testcase_11 AC 529 ms
60,560 KB
testcase_12 AC 452 ms
60,580 KB
testcase_13 AC 447 ms
60,748 KB
testcase_14 AC 539 ms
60,960 KB
testcase_15 AC 220 ms
59,412 KB
testcase_16 AC 243 ms
61,908 KB
testcase_17 AC 209 ms
58,816 KB
testcase_18 AC 244 ms
59,448 KB
testcase_19 AC 256 ms
59,804 KB
testcase_20 AC 284 ms
60,484 KB
testcase_21 AC 292 ms
61,012 KB
testcase_22 AC 356 ms
60,784 KB
testcase_23 AC 483 ms
60,896 KB
testcase_24 AC 527 ms
60,696 KB
testcase_25 AC 606 ms
60,800 KB
testcase_26 AC 574 ms
61,832 KB
testcase_27 AC 524 ms
60,444 KB
testcase_28 AC 538 ms
60,700 KB
testcase_29 AC 575 ms
61,384 KB
testcase_30 AC 566 ms
62,448 KB
testcase_31 AC 569 ms
60,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = sc.nextInt();
		Arrays.sort(ar);
		
		boolean F = true;
		int dif = ar[1]-ar[0];
		for (int i=1; i<n; i++) {
			if (ar[i]-ar[i-1] != dif) {
				F = false; break;
			}
			else if (ar[i]-ar[i-1] == 0) {
				F = false; break;
			}
		}
		
		System.out.println(F?"YES":"NO");
		
	}
}
0