結果

問題 No.406 鴨等間隔の法則
ユーザー nCk_cv
提出日時 2016-08-27 15:05:58
言語 Java
(openjdk 23)
結果
AC  
実行時間 720 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 4,480 ms
コンパイル使用メモリ 75,104 KB
実行使用メモリ 50,348 KB
最終ジャッジ日時 2024-07-07 11:39:39
合計ジャッジ時間 19,610 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int[] l = new int[N];
			for(int i = 0; i < N; i++) {
				l[i] = sc.nextInt();
			}
			Arrays.sort(l);
			int tmp = l[1] - l[0];
			boolean ok = true;
			for(int i = 1; i < N-1; i++) {
				if(tmp != l[i+1] - l[i]) {
					ok = false;
					break;
				}
			}
			if(tmp == 0) ok = false;
			
			System.out.println((ok?"YES":"NO"));
			
		}
}
0