Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6411 | Accepted: 2097 |
Description
Input
Each test case contains three parts.
The first part is two numbers N K, whose meanings we have talked about just now. We denote the nodes by 1 2 ... N. Since it is a tree, each node can reach any other in only one route. (1<=N<=100, 0<=K<=200)
The second part contains N integers (All integers are nonnegative and not bigger than 1000). The ith number is the amount of apples in Node i.
The third part contains N-1 line. There are two numbers A,B in each line, meaning that Node A and Node B are adjacent.
Input will be ended by the end of file.
Note: Wshxzt starts at Node 1.
Output
Sample Input
1 3Sample Output
11
2
Source
#include <iostream>
#include <cstdio> #include <cstring> #include <vector> using namespace std; vector<int> g[200]; void Tree_Dp(int s) int main() |
* This source code was highlighted by YcdoiT. ( style: Codeblocks )