hiho week 76 register

Ended

Participants:183

Verdict:Accepted
Score:100 / 100
Submitted:2015-12-14 16:43:17

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int inf = -2147483647;
vector<int> children[101];
size_t n, m, k;
int dp[101][101];
int attractive[101];
void dfs(int u, int v)
{
    dp[u][1] = attractive[u];
    for (size_t i = 0; i < children[u].size(); i++)
    {
        dfs(children[u][i], u);
        for (size_t x = m; x >= 1; x--)
        {
            if (dp[u][x] > inf)
                for (size_t y = 0; y <= m - x; y++)
                    if (dp[children[u][i]][y] != inf)
                        dp[u][x + y] = max(dp[u][x + y], dp[u][x] + dp[children[u][i]][y]);
        }
    }
}
int main()
{
    int t;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX