結果

問題 No.1219 Mancala Combo
ユーザー poohbear
提出日時 2020-09-04 21:42:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,164 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 197,392 KB
最終ジャッジ日時 2025-01-14 05:23:19
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 20 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

/*累積和
query(l,r)=引数に渡したvectorにおける[l,r)の和(0-indexed)
verified : https://judge.yosupo.jp/problem/static_range_sum
*/

template<typename T>
struct CumulativeSum{
    vector<T> res;
    CumulativeSum(const vector<T> vec){//初期化
        int sz = vec.size();
        res.resize(sz+1,0);
        for(int i=0;i<=sz;i++){
            res[i+1] = res[i]+vec[i];
        }
    }

    T query(int l, int r){
        return res[r]-res[l];
    }
};

int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    CumulativeSum<ll>cum(a);
    for(int i=0;i<n;i++){
        if(cum.query(i,n)%(i+1)!=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

0