結果

問題 No.406 鴨等間隔の法則
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 21:54:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 628 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 71,992 KB
実行使用メモリ 61,952 KB
最終ジャッジ日時 2023-09-21 18:44:22
合計ジャッジ時間 17,887 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 443 ms
60,800 KB
testcase_01 AC 123 ms
55,896 KB
testcase_02 AC 123 ms
56,328 KB
testcase_03 AC 127 ms
55,708 KB
testcase_04 AC 612 ms
60,720 KB
testcase_05 AC 409 ms
60,512 KB
testcase_06 AC 413 ms
60,688 KB
testcase_07 AC 418 ms
60,460 KB
testcase_08 AC 565 ms
60,464 KB
testcase_09 AC 611 ms
61,068 KB
testcase_10 AC 430 ms
60,536 KB
testcase_11 AC 547 ms
61,032 KB
testcase_12 AC 467 ms
60,636 KB
testcase_13 AC 481 ms
60,728 KB
testcase_14 AC 558 ms
60,548 KB
testcase_15 AC 229 ms
57,308 KB
testcase_16 AC 248 ms
61,884 KB
testcase_17 AC 211 ms
58,768 KB
testcase_18 AC 248 ms
59,512 KB
testcase_19 AC 266 ms
60,820 KB
testcase_20 AC 285 ms
60,476 KB
testcase_21 AC 282 ms
60,992 KB
testcase_22 AC 349 ms
60,644 KB
testcase_23 AC 474 ms
60,836 KB
testcase_24 AC 534 ms
60,456 KB
testcase_25 AC 628 ms
59,068 KB
testcase_26 AC 597 ms
61,952 KB
testcase_27 AC 556 ms
60,356 KB
testcase_28 AC 547 ms
61,032 KB
testcase_29 AC 598 ms
61,792 KB
testcase_30 AC 582 ms
60,948 KB
testcase_31 AC 581 ms
58,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public 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 isSatisfy = true;
		int dif = ar[1] - ar[0];
		for (int i=0; i<n-1; i++) {
			if (dif != ar[i+1]-ar[i]) {isSatisfy = false; break;}
			else if (ar[i+1]==ar[i]) {isSatisfy = false; break;}
		}
		System.out.println(isSatisfy==true?"YES":"NO");
	}
}
0