結果

問題 No.406 鴨等間隔の法則
ユーザー atkrymatkrym
提出日時 2016-10-18 11:56:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 772 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 4,263 ms
コンパイル使用メモリ 73,588 KB
実行使用メモリ 67,568 KB
最終ジャッジ日時 2023-09-21 18:17:07
合計ジャッジ時間 21,749 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 480 ms
60,616 KB
testcase_01 AC 125 ms
55,744 KB
testcase_02 AC 124 ms
55,760 KB
testcase_03 AC 128 ms
55,920 KB
testcase_04 AC 728 ms
63,228 KB
testcase_05 AC 457 ms
60,760 KB
testcase_06 AC 468 ms
60,824 KB
testcase_07 AC 463 ms
60,824 KB
testcase_08 AC 695 ms
67,364 KB
testcase_09 AC 772 ms
67,280 KB
testcase_10 AC 500 ms
60,580 KB
testcase_11 AC 661 ms
64,036 KB
testcase_12 AC 538 ms
61,292 KB
testcase_13 AC 550 ms
60,532 KB
testcase_14 AC 685 ms
64,964 KB
testcase_15 AC 236 ms
59,544 KB
testcase_16 AC 273 ms
59,856 KB
testcase_17 AC 213 ms
58,868 KB
testcase_18 AC 253 ms
59,972 KB
testcase_19 AC 281 ms
60,576 KB
testcase_20 AC 309 ms
60,480 KB
testcase_21 AC 318 ms
60,436 KB
testcase_22 AC 390 ms
60,844 KB
testcase_23 AC 541 ms
60,696 KB
testcase_24 AC 629 ms
63,500 KB
testcase_25 AC 760 ms
67,568 KB
testcase_26 AC 759 ms
67,328 KB
testcase_27 AC 605 ms
62,852 KB
testcase_28 AC 584 ms
63,268 KB
testcase_29 AC 739 ms
65,208 KB
testcase_30 AC 751 ms
67,196 KB
testcase_31 AC 719 ms
67,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<n;i++) {
            list.add(sc.nextInt());
        }
        
        Collections.sort(list);
        
        int diff = list.get(1) - list.get(0);
        
        for (int i=1;i<n-1;i++) {
            int tmp = list.get(i+1) - list.get(i);
            if (tmp != diff || tmp == 0) {
                System.out.println("NO");
                return;
            }
        }
        
        System.out.println("YES");
    }
}
0