結果

問題 No.406 鴨等間隔の法則
ユーザー TwinkleStar74
提出日時 2017-10-29 16:08:18
言語 Java
(openjdk 23)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 3,048 ms
コンパイル使用メモリ 75,796 KB
実行使用メモリ 50,692 KB
最終ジャッジ日時 2024-07-07 12:15:10
合計ジャッジ時間 9,610 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class No406 {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		int[] nums = new int[n];
		for(int i=0; i < n; i++) nums[i] = Integer.parseInt(str[i]);
		Arrays.sort(nums);
		int difference = nums[1] - nums[0];
		int count = 0;
		if(difference != 0){
			for(int i=1; i< n-1; i++)
				if((nums[i+1] - nums[i]) == difference){
					count++;
				}
		}
		if(count == n-2) System.out.println("YES");
		else System.out.println("NO");
	}
}
0