{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"MD","content":"圣诞节到了!\n为了装饰 Rabbit House,心爱和智乃买了一棵圣诞树!\n圣诞树有 N 个节点,第 i 个点上有 A_i 个礼物。\n心爱每次可以选取两个不同的叶子节点 x,y,把 x 到 y 路径上的点的礼物各取走一个。\n注意,如果路径上存在至少一个点没有礼物,那么心爱就不能选取这条路径。\n智乃想知道,心爱能否通过若干次操作,使得整棵树上的礼物都被取完,如果可以,输出 \"YES\",否则输出 \"NO\"。"}},{"title":"Constraints","value":{"format":"MD","content":"2 \\leq N \\leq 10^5\n0 \\leq A_i \\leq 10^9\n保证输入是一棵树"}},{"title":"Input","value":{"format":"MD","content":"第一行输入一个整数 N。\n第二行输入 N 个整数 A_i。\n接下来 N-1 行,每行两个正整数表示一条边。"}},{"title":"Sample Input 1","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e5\n1 2 1 1 2\n2 4\n5 2\n3 2\n1 3\n\u003c/pre\u003e"}},{"title":"Sample Output 1","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003eYES\n\u003c/pre\u003e \n选取路径 4~5 与路径 1~5。"}},{"title":"Sample Input 2","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e3\n1 2 1\n1 2\n2 3\n\u003c/pre\u003e"}},{"title":"Sample Output 2","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003eNO\n\u003c/pre\u003e"}},{"title":"Sample Input 3","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003e6\n3 2 2 2 2 2\n1 2\n2 3\n1 4\n1 5\n4 6\n\u003c/pre\u003e"}},{"title":"Sample Output 3","value":{"format":"MD","content":"\u003ch3\u003e\u003c/h3\u003e\n\u003cpre\u003eYES\n\u003c/pre\u003e"}}]}