結果

問題 No.406 鴨等間隔の法則
ユーザー shinwisteriashinwisteria
提出日時 2017-03-30 23:57:05
言語 Java19
(openjdk 21)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 4,730 ms
コンパイル使用メモリ 72,880 KB
実行使用メモリ 61,972 KB
最終ジャッジ日時 2023-09-21 18:25:37
合計ジャッジ時間 19,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 417 ms
60,800 KB
testcase_01 AC 117 ms
56,520 KB
testcase_02 AC 118 ms
56,068 KB
testcase_03 AC 119 ms
56,100 KB
testcase_04 AC 573 ms
60,788 KB
testcase_05 AC 393 ms
60,676 KB
testcase_06 AC 395 ms
60,364 KB
testcase_07 AC 402 ms
60,988 KB
testcase_08 AC 543 ms
60,464 KB
testcase_09 AC 591 ms
60,808 KB
testcase_10 AC 441 ms
60,852 KB
testcase_11 AC 538 ms
60,588 KB
testcase_12 AC 451 ms
59,100 KB
testcase_13 AC 467 ms
60,568 KB
testcase_14 AC 527 ms
60,580 KB
testcase_15 AC 219 ms
58,808 KB
testcase_16 AC 239 ms
59,660 KB
testcase_17 AC 209 ms
59,192 KB
testcase_18 AC 245 ms
60,364 KB
testcase_19 AC 254 ms
60,236 KB
testcase_20 AC 283 ms
61,180 KB
testcase_21 AC 288 ms
60,932 KB
testcase_22 AC 355 ms
60,940 KB
testcase_23 AC 460 ms
60,912 KB
testcase_24 AC 515 ms
60,848 KB
testcase_25 AC 594 ms
60,640 KB
testcase_26 AC 571 ms
61,436 KB
testcase_27 AC 537 ms
61,080 KB
testcase_28 AC 519 ms
61,228 KB
testcase_29 AC 569 ms
60,864 KB
testcase_30 AC 567 ms
61,972 KB
testcase_31 AC 556 ms
58,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Kamo {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		boolean tof = true;
		int[] x = new int[N];
		for(int i = 0;i < N;i++){
			x[i] = s.nextInt();
		}
		s.close();
		Arrays.sort(x);
		final int d = x[1]-x[0];
		for(int i = 1;i < N;i++){
			if(x[i] == x[i-1] || x[i]-x[i-1] != d){
				tof =false;
				break;
			}
		}
		if(tof){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}
0