結果

問題 No.406 鴨等間隔の法則
ユーザー Ichimiya
提出日時 2020-05-03 10:12:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 173,212 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 15:19:10
合計ジャッジ時間 3,140 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.at(i) = x;
	}

	sort(v.begin(), v.end());
	int d = 0;
	for (int i = 1; i < n; i++) {
		int x = v.at(i) - v.at(i - 1);
		if (!x) {
			cout << "NO" << endl;
			return 0;
		}

		if (i == 1) {
			d = x;
		}
		else {
			if (x != d) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	cout << "YES" << endl;
}
0