結果
| 問題 | No.406 鴨等間隔の法則 |
| コンテスト | |
| ユーザー |
@abcde
|
| 提出日時 | 2019-02-11 22:47:02 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 2,000 ms |
| コード長 | 587 bytes |
| 記録 | |
| コンパイル時間 | 1,032 ms |
| コンパイル使用メモリ | 184,872 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2026-03-29 02:55:00 |
| 合計ジャッジ時間 | 2,900 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
// 1. 入力情報取得.
int N;
cin >> N;
LL X[N];
map<LL, int> m;
for(int i = 0; i < N; i++){
LL x;
cin >> x;
m[x]++;
X[i] = x;
}
// 2. 間隔を確認.
sort(X, X + N);
map<LL, int> diff;
for(int i = 0; i < N - 1; i++){
LL d = X[i + 1] - X[i];
diff[d]++;
}
// 3. 後処理.
bool ans = (diff.size() == 1 && m.size() == N);
cout << (ans ? "YES" : "NO") << endl;
return 0;
}
@abcde