結果

問題 No.1884 Sequence
ユーザー gazellegazelle
提出日時 2022-03-25 21:43:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,479 bytes
コンパイル時間 2,366 ms
コンパイル使用メモリ 206,396 KB
実行使用メモリ 17,256 KB
最終ジャッジ日時 2024-04-22 06:24:18
合計ジャッジ時間 7,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 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 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 260 ms
17,124 KB
testcase_11 AC 260 ms
17,120 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 17 ms
5,376 KB
testcase_15 AC 111 ms
10,216 KB
testcase_16 AC 246 ms
17,248 KB
testcase_17 WA -
testcase_18 AC 108 ms
11,364 KB
testcase_19 AC 67 ms
9,312 KB
testcase_20 AC 84 ms
8,544 KB
testcase_21 AC 55 ms
6,632 KB
testcase_22 AC 98 ms
9,320 KB
testcase_23 AC 243 ms
17,120 KB
testcase_24 AC 239 ms
17,256 KB
testcase_25 AC 243 ms
17,256 KB
testcase_26 AC 249 ms
17,248 KB
testcase_27 AC 13 ms
5,376 KB
testcase_28 AC 13 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 13 ms
5,376 KB
testcase_31 AC 89 ms
9,060 KB
testcase_32 AC 231 ms
16,484 KB
testcase_33 AC 43 ms
5,376 KB
testcase_34 AC 44 ms
5,376 KB
testcase_35 AC 16 ms
5,376 KB
testcase_36 AC 33 ms
5,376 KB
testcase_37 AC 44 ms
5,480 KB
testcase_38 AC 40 ms
5,476 KB
testcase_39 AC 20 ms
5,376 KB
testcase_40 AC 22 ms
5,376 KB
testcase_41 AC 177 ms
13,796 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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