Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <vector>using namespace std;int n, m;int score[100];int f[100][100+1];vector<int> edge[100];void getData() {cin >> n >> m;for (int i=0; i<n; i++) cin >> score[i];int lhs, rhs;edge[0].push_back(0);for (int i=0; i<n-1; i++) {cin >> lhs >> rhs;lhs--;rhs--;if (edge[lhs].size() == 0) swap(lhs, rhs);edge[lhs].push_back(rhs);edge[rhs].push_back(rhs);}}void calc(int root) {if (edge[root].size() == 1) {f[root][1] = score[root];} else {f[root][1] = score[root];for (int i=1; i<edge[root].size(); i++) {