結果

問題 No.406 鴨等間隔の法則
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-08-14 11:11:02
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 837 bytes
コンパイル時間 2,535 ms
コンパイル使用メモリ 75,248 KB
実行使用メモリ 50,344 KB
最終ジャッジ日時 2024-04-24 20:23:57
合計ジャッジ時間 17,706 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 426 ms
48,452 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 105 ms
40,324 KB
testcase_04 AC 590 ms
48,624 KB
testcase_05 AC 369 ms
47,524 KB
testcase_06 AC 435 ms
48,608 KB
testcase_07 AC 370 ms
47,208 KB
testcase_08 AC 569 ms
48,652 KB
testcase_09 AC 628 ms
48,884 KB
testcase_10 AC 419 ms
48,512 KB
testcase_11 AC 554 ms
48,552 KB
testcase_12 AC 458 ms
48,008 KB
testcase_13 AC 465 ms
48,284 KB
testcase_14 RE -
testcase_15 AC 211 ms
45,988 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 497 ms
48,392 KB
testcase_24 RE -
testcase_25 AC 593 ms
48,672 KB
testcase_26 RE -
testcase_27 AC 495 ms
48,376 KB
testcase_28 AC 454 ms
49,880 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 613 ms
48,804 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();
        int[] x = new int[n];

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

        Arrays.sort(x);

        int diff = x[1] - x[0];
        boolean bool = true;

        for(int i=1; i<n; i++) {
            if(x[i+1] == x[i]) {
                bool = false;
                break;
            }
            int temp = x[i+1] - x[i];
            if(temp == diff) continue;
        }

        if(bool == true) {
            System.out.println("YES");
        } else if(bool == false) {
            System.out.println("NO");
        }

        in.close();
    }
}
0