結果

問題 No.406 鴨等間隔の法則
ユーザー cb_4150
提出日時 2017-08-16 23:09:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 496 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 59,160 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-07 10:40:24
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 23 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

#define MAX 100000

int main() {
	unsigned int n, a[MAX];
	std::cin >> n;

	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}

	std::sort(a, a + MAX);

	int r = a[1] - a[0];
	if (r == 0) {
		std::cout << "NO" << std::endl;
		return 0;
	}

	for (int i = 2; i < n; i++) {
		if ((r != a[i] - a[i - 1]) || (a[i] == a[i - 1])) {
			std::cout << "NO" << std::endl;
			return 0;
		}

		r = a[i] - a[i - 1];
	}

	std::cout << "YES" << std::endl;

	return 0;
}
0