8124: BZOJ4124:[Baltic2015]Tug of war
Description
输入格式
The first line of input contains a positive integer n, specifying the number of spots on each side of the rope, and an integer K<=20N, specifying the maximum difference of teams' strengths. For simplicity, we number the contestants from 1 to 2N. Each of the following 2N lines describes one contestant: the i-th of these lines contains three positive integers Li, Ri and Si(1<=Li,Ri<=N,1<=Si<=20), which specify that contestant i has strength si and wants to use either spot li on the left side of the rope or spot Ri on the right side of the rope.
输出格式
In the first and only line of output your program should write either YES or NO, depending on whether it is possible to create two teams satisfying the requirements stated above.
样例输入
4 1 1 1 1 2 1 2 2 2 8 1 2 2 3 3 5 3 3 2 4 4 1 4 4 2
样例输出
YES
提示
Explanation to the example: In the first example we can assign contestants 1, 3, 6 and 7 to the left side (which results in a team of strength 1+8+2+1=12 and contestants 2, 4, 5 and 8 to the right side (which results in a team of strength 2+2+5+2=11. The difference of strengths between teams is 1.
求译文!请发至lydsy2012@163.com
题目来源
没有写明来源