結果
問題 |
No.1884 Sequence
|
ユーザー |
|
提出日時 | 2022-07-28 15:29:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 267 ms / 2,000 ms |
コード長 | 1,097 bytes |
コンパイル時間 | 4,443 ms |
コンパイル使用メモリ | 258,264 KB |
最終ジャッジ日時 | 2025-01-30 14:41:06 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair<int, int> #define LP pair<ll, ll> #define fi first #define se second #define pb push_back #define eb emplace_back #define all(s) s.begin(), s.end() #define rall(s) s.rbegin(), s.rend() template<class T> void chmax(T& a, T b) { a = max(a, b); }; template<class T> void chmin(T& a, T b) { a = min(a, b); }; int main() { int n; cin >> n; vector<ll> a; set<ll> s; ll cnt1 = 0; rep(i,n) { ll x; cin >> x; if (x == 0) cnt1++; else { a.pb(x); s.insert(x); } } if (a.size() <= 1 || s.size() <= 1) { cout << "Yes" << endl; return 0; } sort(all(a)); ll g = a[1]-a[0]; rep(i,a.size()-1) { if (a[i+1]-a[i] == 0) { cout << "No" << endl; return 0; } g = gcd(g, a[i+1]-a[i]); } ll cnt2 = 0; rep(i,a.size()-1) { cnt2 += (a[i+1]-a[i])/g-1; } if (cnt1 >= cnt2) cout << "Yes" << endl; else cout << "No" << endl; return 0; }