結果

問題 No.406 鴨等間隔の法則
ユーザー TakaTaka
提出日時 2016-09-07 12:42:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 3,229 ms
コンパイル使用メモリ 72,600 KB
実行使用メモリ 62,792 KB
最終ジャッジ日時 2023-09-21 18:07:53
合計ジャッジ時間 18,509 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 417 ms
60,816 KB
testcase_01 AC 118 ms
56,032 KB
testcase_02 AC 117 ms
55,788 KB
testcase_03 AC 118 ms
55,844 KB
testcase_04 AC 575 ms
60,320 KB
testcase_05 AC 394 ms
60,660 KB
testcase_06 AC 398 ms
60,452 KB
testcase_07 AC 396 ms
60,704 KB
testcase_08 AC 540 ms
59,148 KB
testcase_09 AC 599 ms
62,792 KB
testcase_10 AC 423 ms
60,788 KB
testcase_11 AC 540 ms
60,456 KB
testcase_12 AC 453 ms
60,876 KB
testcase_13 AC 462 ms
60,848 KB
testcase_14 AC 555 ms
60,580 KB
testcase_15 AC 209 ms
58,956 KB
testcase_16 AC 238 ms
60,288 KB
testcase_17 AC 206 ms
58,732 KB
testcase_18 AC 235 ms
59,168 KB
testcase_19 AC 250 ms
59,608 KB
testcase_20 AC 276 ms
60,532 KB
testcase_21 AC 286 ms
60,496 KB
testcase_22 AC 338 ms
60,152 KB
testcase_23 AC 463 ms
60,724 KB
testcase_24 AC 524 ms
61,144 KB
testcase_25 AC 591 ms
61,056 KB
testcase_26 AC 564 ms
61,740 KB
testcase_27 AC 520 ms
60,576 KB
testcase_28 AC 550 ms
60,824 KB
testcase_29 AC 567 ms
61,664 KB
testcase_30 AC 562 ms
61,836 KB
testcase_31 AC 559 ms
61,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class a{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		
        int a=sc.nextInt();
		int num[]=new int[a];
		int flg=0, sub=0;
		for(int i=0; i<a; i++){
			num[i]=sc.nextInt();
		}
		Arrays.sort(num);
		
		sub=num[1]-num[0];
		
		for(int i=0; i<a-1; i++){
			if(num[i]==num[i+1]){
				flg=1;
			}
			if(num[i+1]-num[i]!=sub){
				flg=1;
			}
		}
		
		if(flg==1){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
    }
}
0