結果

問題 No.406 鴨等間隔の法則
ユーザー Eclair1015
提出日時 2018-07-10 20:48:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 64,916 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 12:42:06
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include<string>

using namespace std;
int main(){
	int n;
	cin >> n;
	bool flag = false;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	sort(a.begin(), a.end());
	int div = a[1] - a[0];
	for (int i = 1; i < n; i++) {
		if (div != a[i] - a[i - 1]) {
			flag = true;
		}
	}
	if (flag || div==0)cout << "NO" << endl;
	else cout << "YES" << endl;
}
0