結果

問題 No.406 鴨等間隔の法則
ユーザー samplelpmassamplelpmas
提出日時 2017-01-26 11:26:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 591 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 72,484 KB
実行使用メモリ 62,540 KB
最終ジャッジ日時 2023-09-21 18:32:16
合計ジャッジ時間 16,644 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 418 ms
60,684 KB
testcase_01 AC 117 ms
55,908 KB
testcase_02 AC 118 ms
55,860 KB
testcase_03 AC 119 ms
54,512 KB
testcase_04 AC 573 ms
60,800 KB
testcase_05 AC 400 ms
60,564 KB
testcase_06 AC 398 ms
60,980 KB
testcase_07 AC 399 ms
60,788 KB
testcase_08 AC 547 ms
60,884 KB
testcase_09 AC 587 ms
61,240 KB
testcase_10 AC 413 ms
61,100 KB
testcase_11 AC 521 ms
60,416 KB
testcase_12 AC 456 ms
60,292 KB
testcase_13 AC 437 ms
61,024 KB
testcase_14 AC 540 ms
60,772 KB
testcase_15 AC 224 ms
59,140 KB
testcase_16 AC 241 ms
60,208 KB
testcase_17 AC 208 ms
58,816 KB
testcase_18 AC 237 ms
59,516 KB
testcase_19 AC 254 ms
60,492 KB
testcase_20 AC 277 ms
60,608 KB
testcase_21 AC 290 ms
60,764 KB
testcase_22 AC 344 ms
60,368 KB
testcase_23 AC 458 ms
61,212 KB
testcase_24 AC 509 ms
60,796 KB
testcase_25 AC 591 ms
60,872 KB
testcase_26 AC 570 ms
61,784 KB
testcase_27 AC 528 ms
60,792 KB
testcase_28 AC 532 ms
60,640 KB
testcase_29 AC 581 ms
61,752 KB
testcase_30 AC 574 ms
62,540 KB
testcase_31 AC 562 ms
61,128 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 ducks = sc.nextInt();

        int[] x = new int[ducks];

        for (int i = 0; i < ducks; i++) {
            x[i] = sc.nextInt();
        }

        Arrays.sort(x);

        int diff = x[1] - x[0];

        if (diff == 0) {
            System.out.println("NO");
            return;
        }

        for (int i = 1; i < ducks; i++) {

            if (x[i] - x[i - 1] != diff) {
                System.out.println("NO");
                return;
            }

        }

        System.out.println("YES");

    }

}
0