結果

問題 No.406 鴨等間隔の法則
ユーザー TatsuDX
提出日時 2016-09-03 14:29:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 605 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 2,800 ms
コンパイル使用メモリ 74,892 KB
実行使用メモリ 59,920 KB
最終ジャッジ日時 2024-07-07 11:42:43
合計ジャッジ時間 17,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(), s;
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(t);
		s = t[1] - t[0];
		if (s == 0) {
			System.out.println("NO");
			return;
		}
		for (int i = 2; i < n; i++) {
			if (s != t[i] - t[i - 1]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}
0