結果

問題 No.3220 Forest Creation
ユーザー Brandon Li
提出日時 2025-08-01 22:04:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 72,908 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-02 00:01:19
合計ジャッジ時間 2,225 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#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