結果

問題 No.1219 Mancala Combo
ユーザー 钟梓皓钟梓皓
提出日時 2020-09-04 21:30:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 1,772 ms
コンパイル使用メモリ 191,144 KB
最終ジャッジ日時 2025-01-14 05:07:14
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%lld", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

const int N = 200010;
using ll = long long;

ll a[N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i){
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i <= n; ++ i){
        if (a[i] > i){
            puts("No");
            return 0;
        }
    }
    ll offset = 0;
    for (int i = n; i >= 1; -- i){
        a[i] += offset;
        if (a[i] % i){
            puts("No");
            return 0;
        }
        offset += a[i] / i;
    }
    puts("Yes");
    return 0;
}
0