結果

問題 No.3220 Forest Creation
コンテスト
ユーザー elphe
提出日時 2025-08-01 22:40:04
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 6 ms / 2,000 ms
+ 984µs
コード長 759 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,016 ms
コンパイル使用メモリ 164,180 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-22 06:23:02
合計ジャッジ時間 3,606 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0