#P1342. [CERC1998] 请柬
[CERC1998] 请柬
Description
They have printed invitation cards and all the necessary information and plans. Many students are hired to distribute these invitations. Each student volunteer is assigned exactly one bus stop where he or she will stay for the whole day, inviting people to participate.
The bus system here is very special: there are stops and routes; all routes are one-way, connecting two stops. A bus departs from its origin and, after reaching its destination, returns empty to its origin.
Each morning, the students depart from the headquarters at stop , take buses to their assigned stop, and invite passengers there. Exactly one student is scheduled at each stop. At the end of the day, all students return to the headquarters. Now you need to find the minimal possible sum of bus fares required for the students.
Input Format
The first line contains two integers and .
Lines through each contain three integers , indicating that there is a one-way route from to with fare .
Output Format
Output a single line with one integer, the minimal total fare.
4 6
1 2 10
2 1 60
1 3 20
3 4 10
2 4 5
4 1 50
210
Hint
Constraints
For of the testdata, it is guaranteed that:
- .
- , .
- Every stop is reachable from .
Translated by ChatGPT 5
京公网安备 11011102002149号