結果
| 問題 |
No.3220 Forest Creation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-02 00:13:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 1,894 ms |
| コンパイル使用メモリ | 196,276 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-08-02 00:13:54 |
| 合計ジャッジ時間 | 3,693 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N+1);
for(auto &a : A) cin >> a;
long long sum = 0;
for(int i=1; i<=N; i++) sum += 1LL*A.at(i)*i;
long long deg = 0;
for(int i=2; i<=N; i++) if(A.at(i)){
if(deg == 0) deg = i,A.at(i)--;
deg += 1LL*A.at(i)*(i-2);
}
int a0 = A.at(1);
if(deg == 0){
if(a0%2 == 0) cout << "Yes\n";
else cout << "No\n";
}
else{
if(sum%2){cout << "No\n"; return 0;}
a0 -= deg-1; a0++;
if(a0 > 0 && a0%2 == 0) cout << "Yes\n";
else cout << "No\n";
}
}