結果

問題 No.406 鴨等間隔の法則
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-29 16:34:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 739 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 3,725 ms
コンパイル使用メモリ 73,416 KB
実行使用メモリ 67,384 KB
最終ジャッジ日時 2023-09-21 18:39:37
合計ジャッジ時間 20,068 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 452 ms
63,112 KB
testcase_01 AC 117 ms
55,868 KB
testcase_02 AC 117 ms
55,880 KB
testcase_03 AC 118 ms
54,172 KB
testcase_04 AC 717 ms
67,168 KB
testcase_05 AC 434 ms
61,064 KB
testcase_06 AC 423 ms
61,072 KB
testcase_07 AC 444 ms
60,916 KB
testcase_08 AC 672 ms
67,384 KB
testcase_09 AC 739 ms
66,272 KB
testcase_10 AC 467 ms
60,888 KB
testcase_11 AC 594 ms
60,816 KB
testcase_12 AC 503 ms
60,712 KB
testcase_13 AC 489 ms
60,912 KB
testcase_14 AC 614 ms
62,612 KB
testcase_15 AC 227 ms
59,168 KB
testcase_16 AC 251 ms
60,084 KB
testcase_17 AC 211 ms
58,776 KB
testcase_18 AC 244 ms
60,200 KB
testcase_19 AC 277 ms
60,472 KB
testcase_20 AC 310 ms
61,236 KB
testcase_21 AC 311 ms
60,936 KB
testcase_22 AC 373 ms
60,656 KB
testcase_23 AC 532 ms
60,740 KB
testcase_24 AC 613 ms
60,856 KB
testcase_25 AC 706 ms
66,880 KB
testcase_26 AC 714 ms
67,120 KB
testcase_27 AC 563 ms
62,816 KB
testcase_28 AC 552 ms
62,888 KB
testcase_29 AC 724 ms
67,008 KB
testcase_30 AC 712 ms
67,148 KB
testcase_31 AC 724 ms
67,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No406 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int count = s.nextInt();
        Integer[] arr = new Integer[count];
        String out = "YES";
        for (int i = 0; i < count; i++) {
            arr[i] = s.nextInt();
        }
        Arrays.sort(arr, Comparator.reverseOrder());
        int diff = arr[1] - arr[0];
        if (diff == 0) {
            out = "NO";
        } else {
            for (int i = 1; i < count; i++) {
                if (arr[i] - arr[i - 1] != diff) {
                    out = "NO";
                    break;
                }
            }
        }
        System.out.println(out);
    }
}
0