結果
問題 |
No.3220 Forest Creation
|
ユーザー |
|
提出日時 | 2025-08-01 22:40:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 700 ms |
コンパイル使用メモリ | 85,600 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-02 00:02:05 |
合計ジャッジ時間 | 2,032 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 46 |
ソースコード
#include <iostream> #include <cstdint> #include <vector> static inline constexpr const char* solve(const uint_fast32_t N, const std::vector<uint_fast32_t>& A) noexcept { uint_fast64_t deg_sum = 0; for (uint_fast32_t i = 1; i <= N; ++i) deg_sum += A[i] * i; if ((deg_sum & 1) != 0) return "No"; else if (deg_sum == A[1]) return "Yes"; uint_fast64_t leaf_count = 2; for (uint_fast32_t i = N; i != 1; --i) leaf_count += A[i] * (i - 2); if (leaf_count <= A[1]) return "Yes"; else return "No"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, i; std::cin >> N; std::vector<uint_fast32_t> A(N + 1); for (i = 0; i <= N; ++i) std::cin >> A[i]; std::cout << solve(N, A) << '\n'; return 0; }