結果
問題 |
No.3220 Forest Creation
|
ユーザー |
![]() |
提出日時 | 2025-06-29 15:13:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,101 bytes |
コンパイル時間 | 1,758 ms |
コンパイル使用メモリ | 197,748 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-02 00:00:33 |
合計ジャッジ時間 | 3,269 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N + 1); bool zero = true; for (int i = 0; i <= N; i++) { cin >> A[i]; zero &= (A[i] == 0); } if (zero) { cout << "Yes" << endl; return 0; } while (A[A.size() - 1] == 0) { A.pop_back(); } N = (int)A.size() - 1; if (N >= 2) { ll S = 0, T = 0; for (int i = 2; i <= N; i++) { S += (i - 1) * A[i]; T += A[i]; } ll d1 = 2 + S - T; if ((A[1] - d1) >= 0 && (A[1] - d1) % 2 == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else if (N == 1) { if (A[1] % 2 == 0) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else if (N == 0) { cout << "Yes" << endl; } }