結果

問題 No.1219 Mancala Combo
ユーザー Riuya Hayashi
提出日時 2020-09-05 00:13:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 71,060 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 21:14:05
合計ジャッジ時間 1,933 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

void solve()
{
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    long long cnt = 0;
    while (A[N-1-cnt] == 0) ++cnt;

    vector<int> B(N-cnt);
    for (int i = 0; i < N-cnt; ++i) B[i] = A[i];

    N -= cnt;
    cnt = 0;
    for (int i = 1; i <= N; ++i){
        if ((B[N-i] + cnt) % (N-i+1) == 0) cnt += (B[N-i] + cnt) / (N-i+1);
        else{
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}
0