結果

問題 No.3220 Forest Creation
コンテスト
ユーザー Brandon Li
提出日時 2025-08-01 22:04:45
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 627 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-07-13 18:22:05
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
using ll = long long;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    ll tv = 0;
    ll sum = 0;
    for (int i = 0; i <= n; ++i) {
        cin >> a[i];
        tv += a[i];
        sum += i * a[i];
    }
    if (sum == 0) {
        cout << "Yes\n";
        return 0;
    }
    ll req = 2;
    for (int i = 2; i <= n; ++i) {
        req += (ll)(i - 2) * a[i];
    }
    if (a[1] >= req && sum % 2 == 0) {
        cout << "Yes\n";
    } 
    else {
        cout << "No\n";
    }
    return 0;
}
0