結果

問題 No.1884 Sequence
ユーザー gazellegazelle
提出日時 2022-03-25 21:44:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 1,511 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 206,500 KB
実行使用メモリ 17,256 KB
最終ジャッジ日時 2024-04-22 06:25:07
合計ジャッジ時間 6,510 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 191 ms
17,256 KB
testcase_11 AC 177 ms
17,248 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 81 ms
10,340 KB
testcase_16 AC 167 ms
17,252 KB
testcase_17 AC 42 ms
7,396 KB
testcase_18 AC 71 ms
11,108 KB
testcase_19 AC 55 ms
9,316 KB
testcase_20 AC 63 ms
8,416 KB
testcase_21 AC 39 ms
6,620 KB
testcase_22 AC 73 ms
9,444 KB
testcase_23 AC 174 ms
17,248 KB
testcase_24 AC 175 ms
17,252 KB
testcase_25 AC 167 ms
17,252 KB
testcase_26 AC 180 ms
17,256 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 12 ms
5,376 KB
testcase_29 AC 12 ms
5,376 KB
testcase_30 AC 12 ms
5,376 KB
testcase_31 AC 72 ms
9,064 KB
testcase_32 AC 181 ms
16,488 KB
testcase_33 AC 39 ms
5,376 KB
testcase_34 AC 39 ms
5,376 KB
testcase_35 AC 14 ms
5,376 KB
testcase_36 AC 32 ms
5,376 KB
testcase_37 AC 42 ms
5,376 KB
testcase_38 AC 38 ms
5,472 KB
testcase_39 AC 19 ms
5,376 KB
testcase_40 AC 19 ms
5,376 KB
testcase_41 AC 128 ms
13,796 KB
testcase_42 AC 129 ms
13,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i, n, m) for (long long i = (n); i < (long long)(m); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 998244353;
constexpr ld eps = 1e-6;

template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
    os << to_string(p.first) << " " << to_string(p.second);
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    REP(i, v.size()) {
        if (i) os << " ";
        os << v[i];
    }
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<ll> a;
    map<ll, int> mp;
    int mx = 0;

    REP(i, n) {
        ll num;
        cin >> num;
        if (num != 0) {
            a.pb(num);
            mp[num]++;
            mx = max(mx, mp[num]);
        }
    }

    if ((int)a.size() <= 1) {
        cout << "Yes" << endl;
        return 0;
    }

    sort(ALL(a));

    if (mx >= 2) {
        if (a.front() == a.back()) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }

    ll g = a[1] - a[0];

    FOR(i, 1, a.size()) g = gcd(g, a[i] - a[i - 1]);

    if ((a.back() - a.front()) / g <= n - 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
0