Round 2 (unofficial online mirror, Div. 1 only) B. Work Gro

One Big Software Company hasnemployees numbered from1ton. The director is assigned number1. Every employee of the company except the director has exactly one immediate superior. The director, of course, doesn’t have a superior.

We will call personaa subordinates of another personb, if eitherbis an immediate supervisor ofa, or the immediate supervisor ofais a subordinate to personb. In particular, subordinates of the head are all other employees of the company.

To solve achieve an Important Goal we need to form a workgroup. Every person has some efficiency, expressed by a positive integerai, whereiis the person’s number. The efficiency of the workgroup is defined as the total efficiency of all the people included in it.

The employees of the big software company are obsessed with modern ways of work process organization. Today pair programming is at the peak of popularity, so the workgroup should be formed with the following condition. Each person entering the workgroup should be able to sort all of his subordinates who are also in the workgroup into pairs. In other words, for each of the members of the workgroup the number of his subordinates within the workgroup should be even.

Your task is to determine the maximum possible efficiency of the workgroup formed at observing the given condition. Any person including the director of company can enter the workgroup.

,因为有了梦想,我们才能拥有奋斗的目标,

Round 2 (unofficial online mirror, Div. 1 only) B. Work Gro

相关文章:

你感兴趣的文章:

标签云: