結果

問題 No.406 鴨等間隔の法則
ユーザー togaerror
提出日時 2016-09-07 22:37:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 172,052 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 11:42:51
合計ジャッジ時間 3,152 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
       	int n, flag = 0;
       	cin >> n;
       	vector<int> x(n);
       	for(int i = 0; i < n; i++) cin >> x[i];
       	sort(x.begin(), x.end());

       	int keep;
       	if(x[0] != x[1]) {
       		keep = x[1] - x[0];
       		for(int i = 2; i < n; i++) {
       			if(keep != x[i] - x[i - 1]) {
       				flag = 1;
       				break;
       			}
       		}
       	} else {
       		flag = 1;
       	}

       	if(flag) {
       		cout << "NO" << endl;
       	} else {
       		cout << "YES" << endl;
       	}

       	return 0;
}
0