結果

問題 No.3220 Forest Creation
ユーザー jiangxinyang
提出日時 2025-08-01 22:13:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 1,825 ms
コンパイル使用メモリ 194,740 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-01 22:13:35
合計ジャッジ時間 3,052 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 42 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int N = 200005;
const int INF = 0x3f3f3f3f;
ll a[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) cin >> a[i];
    ll tot = 0, sum = 0;
    for (int i = 0; i <= n; i++) {
        tot += a[i];
        sum += a[i] * i;
    }
    if (tot < 2) {
        if (!sum) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
        return 0;
    }
    if ((sum & 1) || sum > 2 * (tot - 1)) {
        cout << "No\n";
        return 0;
    }
    for (int i = tot; i <= n; i++) {
        if (a[i] > 0) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}
0