結果

問題 No.406 鴨等間隔の法則
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-10 02:35:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 587 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 3,101 ms
コンパイル使用メモリ 72,476 KB
実行使用メモリ 62,840 KB
最終ジャッジ日時 2023-09-21 18:19:13
合計ジャッジ時間 17,835 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 428 ms
60,404 KB
testcase_01 AC 116 ms
55,832 KB
testcase_02 AC 115 ms
55,980 KB
testcase_03 AC 117 ms
55,828 KB
testcase_04 AC 573 ms
60,788 KB
testcase_05 AC 391 ms
62,468 KB
testcase_06 AC 414 ms
60,480 KB
testcase_07 AC 398 ms
60,328 KB
testcase_08 AC 548 ms
60,544 KB
testcase_09 AC 587 ms
62,840 KB
testcase_10 AC 416 ms
60,756 KB
testcase_11 AC 516 ms
61,196 KB
testcase_12 AC 458 ms
60,672 KB
testcase_13 AC 461 ms
60,464 KB
testcase_14 AC 536 ms
60,436 KB
testcase_15 AC 215 ms
59,468 KB
testcase_16 AC 241 ms
59,992 KB
testcase_17 AC 204 ms
56,844 KB
testcase_18 AC 237 ms
59,464 KB
testcase_19 AC 252 ms
59,996 KB
testcase_20 AC 278 ms
60,228 KB
testcase_21 AC 286 ms
60,792 KB
testcase_22 AC 342 ms
60,432 KB
testcase_23 AC 462 ms
60,668 KB
testcase_24 AC 514 ms
61,064 KB
testcase_25 AC 585 ms
60,496 KB
testcase_26 AC 557 ms
62,216 KB
testcase_27 AC 523 ms
61,024 KB
testcase_28 AC 523 ms
60,528 KB
testcase_29 AC 580 ms
61,240 KB
testcase_30 AC 558 ms
62,576 KB
testcase_31 AC 533 ms
61,436 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 [] x = new int [N];
        for(int i=0; i<N; i++){
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int a = x[1]-x[0];
        int flag = 0;
        for(int i=1; i<N; i++){
            if(x[i]-x[i-1]!=a){
                System.out.println("NO");
                flag=1;
                break;
            }
            if(x[i]-x[i-1]==0){
                System.out.println("NO");
                flag=1;
                break;
            }
        }
        if(flag==0){
            System.out.println("YES");
        }
    }
}
0