結果

問題 No.406 鴨等間隔の法則
ユーザー fjafjafjafjafjafja
提出日時 2017-09-16 23:48:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 622 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 3,401 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 62,832 KB
最終ジャッジ日時 2023-09-21 18:36:26
合計ジャッジ時間 19,134 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 437 ms
60,468 KB
testcase_01 AC 124 ms
55,984 KB
testcase_02 AC 125 ms
55,728 KB
testcase_03 AC 124 ms
56,008 KB
testcase_04 AC 601 ms
60,444 KB
testcase_05 AC 411 ms
60,732 KB
testcase_06 AC 412 ms
60,896 KB
testcase_07 AC 412 ms
60,332 KB
testcase_08 AC 579 ms
60,588 KB
testcase_09 AC 621 ms
61,012 KB
testcase_10 AC 437 ms
60,652 KB
testcase_11 AC 552 ms
60,856 KB
testcase_12 AC 473 ms
60,892 KB
testcase_13 AC 482 ms
60,852 KB
testcase_14 AC 568 ms
60,372 KB
testcase_15 AC 226 ms
58,900 KB
testcase_16 AC 243 ms
59,736 KB
testcase_17 AC 203 ms
58,524 KB
testcase_18 AC 242 ms
59,384 KB
testcase_19 AC 259 ms
60,196 KB
testcase_20 AC 289 ms
60,184 KB
testcase_21 AC 298 ms
60,152 KB
testcase_22 AC 349 ms
60,644 KB
testcase_23 AC 484 ms
60,628 KB
testcase_24 AC 576 ms
60,844 KB
testcase_25 AC 622 ms
60,636 KB
testcase_26 AC 592 ms
62,232 KB
testcase_27 AC 560 ms
61,088 KB
testcase_28 AC 565 ms
61,008 KB
testcase_29 AC 596 ms
61,504 KB
testcase_30 AC 601 ms
62,832 KB
testcase_31 AC 582 ms
60,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class N406 {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] x=new int[n];
		int dif=-1;
		String ans="NO";
		for(int i=0;i<n;i++)
		{
			x[i]=sc.nextInt();
		}
		Arrays.sort(x);
		for(int i=1;i<n;i++)
		{
			int buf=x[i]-x[i-1];
			if(buf==0){break;}
			if(dif==-1){dif=buf;continue;}
			if(dif!=buf){break;}
			if(i==n-1){ans="YES";}
		}
		System.out.println(ans);
	}

}
0