結果
| 問題 |
No.3220 Forest Creation
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2025-08-11 01:32:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 989 bytes |
| コンパイル時間 | 3,723 ms |
| コンパイル使用メモリ | 275,128 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-11 01:32:52 |
| 合計ジャッジ時間 | 6,018 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/modint>
using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
/*
次数0の頂点はどうでもいい。
まず、A_i(i>=1)が全て0ならTrue
頂点数V = sum A_i
辺の数E = (sum A_i*i) /2 (ループがないグラフなら辺の数*2=次数の和)
V > Eのときループがないグラフを作れる。
*/
ll N;
cin >> N;
vector<ll> A(N+1);
for (int i=0; i<=N; i++) cin >> A[i];
bool ok=1;
for (int i=1; i<=N; i++) if (A[i] != 0) ok=0;
if (ok){
cout << "Yes" << endl;
return 0;
}
ll V=0, E=0;
for (int i=1; i<=N; i++){
V += A[i];
E += A[i]*i;
}
if (E % 2 == 1){
cout << "No" << endl;
return 0;
}
E /= 2;
cout << (V > E ? "Yes" : "No") << endl;
return 0;
}
srjywrdnprkt