結果

問題 No.406 鴨等間隔の法則
ユーザー samplelpmassamplelpmas
提出日時 2017-01-26 11:15:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 2,896 ms
コンパイル使用メモリ 74,272 KB
実行使用メモリ 52,824 KB
最終ジャッジ日時 2024-04-24 21:51:48
合計ジャッジ時間 18,219 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 447 ms
48,532 KB
testcase_01 WA -
testcase_02 AC 110 ms
41,416 KB
testcase_03 AC 118 ms
41,364 KB
testcase_04 AC 608 ms
48,624 KB
testcase_05 AC 416 ms
48,320 KB
testcase_06 AC 439 ms
48,592 KB
testcase_07 AC 448 ms
48,404 KB
testcase_08 AC 576 ms
48,684 KB
testcase_09 AC 501 ms
48,300 KB
testcase_10 AC 415 ms
48,320 KB
testcase_11 AC 541 ms
48,336 KB
testcase_12 AC 487 ms
48,284 KB
testcase_13 AC 468 ms
48,260 KB
testcase_14 WA -
testcase_15 AC 208 ms
46,108 KB
testcase_16 AC 222 ms
46,980 KB
testcase_17 AC 192 ms
44,668 KB
testcase_18 AC 220 ms
46,036 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 273 ms
47,568 KB
testcase_22 WA -
testcase_23 AC 474 ms
48,296 KB
testcase_24 WA -
testcase_25 AC 576 ms
48,792 KB
testcase_26 WA -
testcase_27 AC 496 ms
48,340 KB
testcase_28 AC 505 ms
48,540 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 577 ms
48,676 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 - 1; i++) {

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

        }

        System.out.println("YES");

    }

}
0