結果

問題 No.3220 Forest Creation
ユーザー nono00
提出日時 2025-08-01 22:36:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,518 bytes
コンパイル時間 2,499 ms
コンパイル使用メモリ 278,888 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-02 00:02:02
合計ジャッジ時間 3,932 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 45 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, vector<T>, greater<T>>;
#define rep2(i, n) for (ll i = 0; i < (n); i++)
#define rep3(i, l, r) for (ll i = (l); i < (r); i++)
#define rrep2(i, n) for (ll i = n; i-- > 0;)
#define rrep3(i, r, l) for (ll i = (r); i-- > (l);)
#define overload(a, b, c, d, ...) d
#define rep(...) overload(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rrep(...) overload(__VA_ARGS__, rrep3, rrep2)(__VA_ARGS__)
#define all(x) begin(x), end(x)
bool chmin(auto& lhs, auto rhs) {
    return lhs > rhs ? lhs = rhs, 1 : 0;
}
bool chmax(auto& lhs, auto rhs) {
    return lhs < rhs ? lhs = rhs, 1 : 0;
}
struct IOIO {
    IOIO() {
        std::cin.tie(0)->sync_with_stdio(0);
    }
} ioio;

void solve() {
    int n;
    cin >> n;
    if (n < 2) {
        cout << "Yes" << endl;
        return;
    }
    vector<ll> a(n + 1);
    rep(i, n + 1) cin >> a[i];
    ll L = 0;
    rep(i, 2, n + 1) L += (i - 1) * a[i];
    if (L != 0) {
        L++;
    }
    ll R = 0;
    rep(i, 2, n + 1) {
        R += i * a[i];
    }
    a[1] -= L;
    if (a[1] < 0) {
        cout << "No" << endl;
        return;
    }
    if (a[1] % 2 == 1 && a[1] <= n && L == R) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}

int main() {
    int t = 1;
    //  cin >> t;
    while (t--) solve();
}
0