結果

問題 No.406 鴨等間隔の法則
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-08-14 11:15:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 601 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 3,981 ms
コンパイル使用メモリ 72,364 KB
実行使用メモリ 62,648 KB
最終ジャッジ日時 2023-09-21 18:01:59
合計ジャッジ時間 19,022 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 426 ms
60,572 KB
testcase_01 AC 117 ms
55,508 KB
testcase_02 AC 117 ms
56,096 KB
testcase_03 AC 120 ms
56,048 KB
testcase_04 AC 582 ms
60,944 KB
testcase_05 AC 391 ms
60,636 KB
testcase_06 AC 399 ms
60,884 KB
testcase_07 AC 404 ms
60,304 KB
testcase_08 AC 548 ms
60,832 KB
testcase_09 AC 593 ms
61,032 KB
testcase_10 AC 430 ms
62,356 KB
testcase_11 AC 528 ms
60,748 KB
testcase_12 AC 462 ms
60,392 KB
testcase_13 AC 459 ms
60,540 KB
testcase_14 AC 545 ms
60,188 KB
testcase_15 AC 222 ms
59,300 KB
testcase_16 AC 245 ms
60,044 KB
testcase_17 AC 204 ms
58,840 KB
testcase_18 AC 236 ms
59,204 KB
testcase_19 AC 255 ms
58,804 KB
testcase_20 AC 281 ms
60,340 KB
testcase_21 AC 290 ms
60,780 KB
testcase_22 AC 339 ms
60,644 KB
testcase_23 AC 485 ms
60,568 KB
testcase_24 AC 508 ms
60,552 KB
testcase_25 AC 601 ms
60,340 KB
testcase_26 AC 578 ms
61,440 KB
testcase_27 AC 549 ms
60,404 KB
testcase_28 AC 553 ms
60,532 KB
testcase_29 AC 579 ms
61,596 KB
testcase_30 AC 588 ms
62,648 KB
testcase_31 AC 562 ms
60,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] x = new long[n];
        for(int i=0; i<n; i++) {
            x[i] = in.nextLong();
        }
        Arrays.sort(x);
        final long diff = x[1] - x[0];
        if(diff == 0) {
            System.out.println("NO");
        } else {
            for(int i=2; i<n; i++) {
                if(diff != x[i] - x[i-1]) {
                    System.out.println("NO");
                    return;
                }
            }
            System.out.println("YES");
        }

        in.close();
    }
}
0