hiho week 76 register

Ended

Participants:183

Verdict:Accepted
Score:100 / 100
Submitted:2015-12-16 20:46:22

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 <cstdio>
 #include <algorithm>
 #include <cstring>
 using namespace std;
 struct node{
      int to;
      int next;
 }e[300];
int act[102];
int dp[102][102];
int n,k,m;
int ct;
int h[102];
void dfs(int x,int fa){
 
 for(int i=h[x];i;i=e[i].next)
   if(e[i].to!=fa)    dfs(e[i].to,x);
 dp[x][1]=act[x];
 for(int i=h[x];i;i=e[i].next){
     int v=e[i].to;
     if(v!=fa){
         for(int j=m;j>1;j--){
             for(int k=1;k<j;k++)
             dp[x][j]=max(dp[x][j-k]+dp[v][k],dp[x][j]);
         }
     }
 }
   
}
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX