結果

問題 No.406 鴨等間隔の法則
ユーザー IchimiyaIchimiya
提出日時 2020-05-03 10:03:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 479 bytes
コンパイル時間 6,281 ms
コンパイル使用メモリ 168,536 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 08:09:48
合計ジャッジ時間 19,749 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 697 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1,387 ms
4,380 KB
testcase_05 AC 331 ms
4,380 KB
testcase_06 AC 242 ms
4,380 KB
testcase_07 AC 261 ms
4,376 KB
testcase_08 AC 1,329 ms
4,380 KB
testcase_09 AC 824 ms
4,380 KB
testcase_10 AC 581 ms
4,376 KB
testcase_11 TLE -
testcase_12 AC 1,164 ms
4,380 KB
testcase_13 AC 515 ms
4,380 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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;

		if (i > 1) {
			int c = count(v.begin(), v.end(), x);
			if (c > 1) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	sort(v.begin(), v.end());
	int d = v.at(1) - v.at(0);
	d *= n - 1;
	//cout << d << endl;

	if (d == v.at(v.size() - 1)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}
0