結果

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> V;
typedef vector<vector<int> > VV;
typedef long long ll;
const int inf = 2e9;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int main()
{
	int n;
	cin >> n;
	priority_queue<int> que;
	rep(i,0,n) {
		int t; cin >> t;
		que.push(t);
	}
	
	int x1 = que.top(); que.pop();
	int x2 = que.top(); que.pop();
	int dif = x1 - x2;

	x1 = x2;
	bool f = true;
	while(!que.empty()) {
		int x2 = que.top(); que.pop();
		if (x1 - x2 != dif) f = false;
		if (x1 == x2) f = false;
		x1 = x2;
	}
	f? cout << "YES" << endl : cout << "NO" << endl;
	return 0;
}
0