結果

問題 No.406 鴨等間隔の法則
ユーザー language_43
提出日時 2016-09-12 18:02:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 77,848 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 11:45:56
合計ジャッジ時間 2,331 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

# include <iostream>
# include <cstring>
# include <string>
# include <vector>
# include <cmath>
# include <sstream>
# include <iomanip>
# include <algorithm>
using namespace std;

# define repl(i, a, b)	for(int i=(int)(a);i<(int)(b);i++)
# define rep(i, n)	repl(i, 0, n)
typedef long long ll;

int main(){
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i, n){
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	int r = abs(v[1] - v[0]);
	repl(i, 1, n-1){
		if(r != abs(v[i] - v[i+1]) || v[i] == v[i+1]){
			//cout << r << endl;
			//cout << v[i+1] - v[i] << endl;
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}
0