結果

問題 No.406 鴨等間隔の法則
ユーザー shinwisteriashinwisteria
提出日時 2017-03-30 23:14:35
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 771 bytes
コンパイル時間 4,277 ms
コンパイル使用メモリ 79,972 KB
実行使用メモリ 65,028 KB
最終ジャッジ日時 2024-04-25 00:55:37
合計ジャッジ時間 10,626 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,668 ms
64,008 KB
testcase_01 AC 114 ms
41,120 KB
testcase_02 AC 109 ms
40,948 KB
testcase_03 AC 115 ms
41,264 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Kamo {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		boolean tof = true;
		ArrayList<Integer> x = new ArrayList<>();
		for(int i = 0;i < N;i++){
			int k = s.nextInt();
			if(!x.contains(k)){
				x.add(k);
			}else{
				tof = false;
			}
		}
		s.close();
		if(tof){
			TreeSet<Integer> y = new TreeSet<>();
			y.addAll(x);
			int p = y.pollFirst();
			final int d = y.first() - p;
			p = y.pollFirst();
			while(y.size() != 0){
				if(y.first() -p != d){
					tof = false;
					break;
				}
				p = y.pollFirst();
				
			}
		}
		if(tof){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}
0