結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2019-03-27 19:56:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 172,816 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 12:36:13 |
合計ジャッジ時間 | 3,297 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; const ll inf = (1 << 30) - 1; const ll infll = (1LL << 61) - 1; int n, d; int main() { cin >> n; vector<int> a; for (int i = 0; i < n; i++) { int p; cin >> p; a.push_back(p); } bool f = 1; sort(a.begin(), a.end()); d = a[1] - a[0]; if (d == 0) f = 0; for (int i = 2; i < n; i++) { if (a[i - 1] + d != a[i]) f = false; } cout << (f ? "YES" : "NO") << endl; }