結果

問題 No.1884 Sequence
ユーザー KichicoKichico
提出日時 2022-03-25 22:35:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,626 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 209,772 KB
実行使用メモリ 9,444 KB
最終ジャッジ日時 2024-04-22 07:17:47
合計ジャッジ時間 5,552 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
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 RE -
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 112 ms
9,440 KB
testcase_11 AC 120 ms
9,444 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 36 ms
5,376 KB
testcase_16 AC 57 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 31 ms
5,376 KB
testcase_19 AC 25 ms
5,376 KB
testcase_20 AC 31 ms
5,376 KB
testcase_21 AC 24 ms
5,376 KB
testcase_22 AC 34 ms
5,376 KB
testcase_23 AC 57 ms
5,376 KB
testcase_24 AC 57 ms
5,376 KB
testcase_25 AC 55 ms
5,476 KB
testcase_26 AC 58 ms
5,476 KB
testcase_27 AC 12 ms
5,376 KB
testcase_28 RE -
testcase_29 AC 12 ms
5,376 KB
testcase_30 AC 12 ms
5,376 KB
testcase_31 AC 31 ms
5,376 KB
testcase_32 AC 58 ms
5,472 KB
testcase_33 AC 44 ms
5,476 KB
testcase_34 AC 44 ms
5,476 KB
testcase_35 AC 15 ms
5,376 KB
testcase_36 AC 33 ms
5,376 KB
testcase_37 AC 44 ms
5,376 KB
testcase_38 AC 41 ms
5,376 KB
testcase_39 AC 19 ms
5,376 KB
testcase_40 AC 21 ms
5,376 KB
testcase_41 AC 47 ms
5,472 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
using ll = int64_t;
using ld = long double;
using ull = unsigned long long;
#define ALL(x) x.begin(),x.end()
#define rep(iter,from,to) for(ll iter=from;iter<to;++iter)
#define fore(variable,container) for(auto& variable:container)
#define forc(variable,container) for(auto& variable:container) cout<<variable<<endl;
const ll MOD = 1e9 + 7;
const ll INF = 1e17;
const vector<ll> dx{ 1,0,-1,0 }, dy{ 0,1,0,-1 };
//#######################################################################
void op(vector<ll> vec) {
    ll size = (ll)vec.size();
    for (ll i = 0; i < size - 1; ++i) cout << vec[i] << " ";
    cout << vec.back() << endl;
}

void op(vector<vector<ll>> vec) {
    ll height = (ll)vec.size();
    ll width = (ll)vec[0].size();
    for (ll i = 0; i < height; ++i) {
        for (ll j = 0; j < width - 1; ++j) cout << vec[i][j] << " ";
        cout << vec[i].back() << endl;
    }
}

void twoText(bool identifier, string outTrue, string outFalse) {
    if (identifier) cout << outTrue << endl;
    else cout << outFalse << endl;
}

void twoText(bool identifier) {
    if (identifier) cout << "Yes" << endl;
    else cout << "No" << endl;
}

template <class T>
T vecsum(vector<T>& vec) {
    return accumulate(ALL(vec), (T)0);
}

template<class T, ll>
T vecsum(vector<T>& vec, ll K) {
    ll ret = 0;
    rep(i, 0, K) ret += vec[i];
    return ret;
}

template <class T>
struct grid {
    vector<vector<T>> field;
    grid(ll height, ll width) { field = vector<vector<T>>(height, vector<T>(width, (T)0)); }
    void input() { rep(i, 0, field.size()) rep(j, 0, field[i].size()) cin >> field[i][j]; }
};

//#########################################################################


void solve() {
    ll N; cin >> N;
    ll zero = 0;
    vector<ll> a; rep(i, 0, N) {
        ll v; cin >> v;
        if (v == 0) zero++;
        else a.emplace_back(v);
    }
    if (a.empty()) { cout << "Yes" << endl; return; }
    sort(ALL(a));
    map<ll,ll> diff;
    rep(i, 0, a.size() - 1) {
        diff[a[i + 1] - a[i]]++;
    }
    auto it = *diff.begin();
    ll mini = it.first;
    ll cnt = 0;
    if (mini == 0) {
        auto itt = *diff.rbegin();
        twoText(itt.first == 0);
        return;
    }
    fore(x, diff) {
        if (x.first % mini != 0) {
            cout << "No" << endl;
            return;
        }
        if (mini != x.first) cnt += (x.first / mini) * x.second;
    }
    twoText(cnt <= zero);
}


int main(void) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}
0