結果

問題 No.3220 Forest Creation
ユーザー kenti
提出日時 2025-08-02 21:16:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 3,106 ms
コンパイル使用メモリ 276,664 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-02 21:16:20
合計ジャッジ時間 5,650 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n + 1);
    for (ll &x : a) cin >> x;
    ll lb = 0, ub = 0;
    for (ll i = 2; i <= n; i++) {
        lb += a[i] * (i - 1);
        ub += a[i] * i;
    }
    if (lb > 0) lb++;
    if (a[1] < lb) {
        cout << "No" << "\n";
        return 0;
    } else if (a[1] <= ub) {
        cout << "Yes" << "\n";
        return 0;
    }
    ll res = a[1] - ub;
    if (res % 2 == 0) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
}
0