結果

問題 No.406 鴨等間隔の法則
ユーザー tentententen
提出日時 2020-11-11 14:51:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 3,180 ms
コンパイル使用メモリ 71,160 KB
実行使用メモリ 63,256 KB
最終ジャッジ日時 2023-09-30 00:32:33
合計ジャッジ時間 17,285 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 426 ms
60,608 KB
testcase_01 AC 119 ms
56,032 KB
testcase_02 AC 119 ms
55,612 KB
testcase_03 AC 119 ms
55,460 KB
testcase_04 AC 565 ms
62,600 KB
testcase_05 AC 394 ms
60,296 KB
testcase_06 AC 398 ms
60,660 KB
testcase_07 AC 400 ms
60,592 KB
testcase_08 AC 545 ms
60,756 KB
testcase_09 AC 587 ms
60,356 KB
testcase_10 AC 421 ms
60,632 KB
testcase_11 AC 522 ms
60,372 KB
testcase_12 AC 464 ms
60,796 KB
testcase_13 AC 447 ms
61,192 KB
testcase_14 AC 542 ms
60,640 KB
testcase_15 AC 221 ms
59,504 KB
testcase_16 AC 239 ms
59,984 KB
testcase_17 AC 205 ms
58,428 KB
testcase_18 AC 241 ms
59,416 KB
testcase_19 AC 258 ms
60,268 KB
testcase_20 AC 280 ms
60,480 KB
testcase_21 AC 286 ms
61,268 KB
testcase_22 AC 340 ms
60,784 KB
testcase_23 AC 453 ms
61,008 KB
testcase_24 AC 510 ms
60,820 KB
testcase_25 AC 594 ms
61,568 KB
testcase_26 AC 571 ms
61,176 KB
testcase_27 AC 518 ms
60,816 KB
testcase_28 AC 531 ms
60,444 KB
testcase_29 AC 570 ms
63,256 KB
testcase_30 AC 577 ms
61,124 KB
testcase_31 AC 565 ms
61,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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