<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>babcs2035</author_name>
  <author_url>https://blog.hatena.ne.jp/babcs2035/</author_url>
  <blog_title>きろく</blog_title>
  <blog_url>https://babcs2035.hateblo.jp/</blog_url>
  <categories>
    <anon>競技プログラミング</anon>
    <anon>Codeforces 問題</anon>
  </categories>
  <description>問題 解法 解答 問題 codeforces.com 解法 b_i を「頂点 i を根とする全て部分木に含まれる s の最小値」とおく．このとき，b_i &lt; s_i であるような頂点が存在したらその木は構成不可能なので -1 を出力すればよい． 木が構成出来る場合，木全体を根から（すなわち頂点 1 から）見ていく．「dfs(i, s) := 今頂点 i を見ていて，パスにある頂点の a の和が sum のとき」と DFS を立てて，a_i = b_i - sum とすればよい．これを全ての頂点について処理し a を求めればよい．O(N)． 解答 codeforces.com</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fbabcs2035.hateblo.jp%2Fentry%2F2019%2F03%2F19%2F065905&quot; title=&quot;Codeforces Round #530 (Div. 1)：A. Sum in the tree - きろく&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn-ak.f.st-hatena.com/images/fotolife/b/babcs2035/20190319/20190319065853.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2019-03-19 06:59:05</published>
  <title>Codeforces Round #530 (Div. 1)：A. Sum in the tree</title>
  <type>rich</type>
  <url>https://babcs2035.hateblo.jp/entry/2019/03/19/065905</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
