結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2023-08-01 02:59:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 751 bytes |
コンパイル時間 | 1,076 ms |
コンパイル使用メモリ | 109,484 KB |
最終ジャッジ日時 | 2025-02-15 21:16:24 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<cctype> #include<set> #include<bitset> #include<math.h> #include<map> #include<queue> #include<iomanip> using namespace std; int main(){ long long n, t1, t2 = -1, d = 0; cin >> n; set<long long> st; for (int i = 0; i < n; i++){ cin >> t1; if (!st.count(t1)) st.insert(t1); else { cout << "NO" << endl; return 0; } } d = *(++st.begin()) - *st.begin(); for (auto x : st){ t1 = x; if (t2 == -1){ t2 = t1; continue; } else if (d != t1 - t2){ cout << "NO" << endl; return 0; } else t2 = t1; } cout << "YES" << endl; }