結果

問題 No.406 鴨等間隔の法則
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-29 16:08:18
言語 Java19
(openjdk 21)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 732 bytes
コンパイル時間 4,068 ms
コンパイル使用メモリ 72,404 KB
実行使用メモリ 62,072 KB
最終ジャッジ日時 2023-09-21 18:39:09
合計ジャッジ時間 11,213 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
56,272 KB
testcase_01 AC 46 ms
49,460 KB
testcase_02 AC 46 ms
47,428 KB
testcase_03 AC 45 ms
49,352 KB
testcase_04 AC 245 ms
61,052 KB
testcase_05 AC 167 ms
56,044 KB
testcase_06 AC 175 ms
56,012 KB
testcase_07 AC 173 ms
56,388 KB
testcase_08 AC 245 ms
60,900 KB
testcase_09 AC 253 ms
61,544 KB
testcase_10 AC 184 ms
56,804 KB
testcase_11 AC 250 ms
61,448 KB
testcase_12 AC 203 ms
56,784 KB
testcase_13 AC 192 ms
57,120 KB
testcase_14 AC 256 ms
61,460 KB
testcase_15 AC 76 ms
51,968 KB
testcase_16 AC 98 ms
52,832 KB
testcase_17 AC 70 ms
51,344 KB
testcase_18 AC 96 ms
52,032 KB
testcase_19 AC 109 ms
52,892 KB
testcase_20 AC 120 ms
52,620 KB
testcase_21 AC 119 ms
53,016 KB
testcase_22 AC 148 ms
55,140 KB
testcase_23 AC 201 ms
56,308 KB
testcase_24 AC 253 ms
61,204 KB
testcase_25 AC 274 ms
61,620 KB
testcase_26 AC 262 ms
61,532 KB
testcase_27 AC 215 ms
60,928 KB
testcase_28 AC 225 ms
59,864 KB
testcase_29 AC 261 ms
61,452 KB
testcase_30 AC 270 ms
62,072 KB
testcase_31 AC 264 ms
61,368 KB
権限があれば一括ダウンロードができます

ソースコード

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