题目链接:http://codeforces.com/problemset/problem/17/B
B. Hierarchy
Nick's company employed n people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are m applications written in the following form:«employee ai is ready to become a supervisor of employeebi at extra costci». The qualificationqj of each employee is known, and for each application the following is true:qai > qbi.
Would you help Nick calculate the minimum cos