#t527. 搭配购买
搭配购买
Combined Purchase
Problem Background
Special for beginners, ^_^
Problem Description
Joe thinks clouds are beautiful, so he decides to go to the mountain shop to buy some clouds. The shop has clouds, numbered , and each cloud has a value. But the shopkeeper tells him that some clouds must be bought together to be worthwhile, so buying one cloud also requires buying all the clouds matched with it.
However, Joe has limited money, so he wants to get as much value as possible.
Input Format
The first line contains , meaning clouds, matches, and Joe has money.
Lines to : each line contains , the price and the value of the -th cloud.
Lines to : each line contains , meaning buying requires buying , and similarly buying requires buying .
Output Format
One line: the maximum value obtainable.
Sample Input
5 3 10
3 10
3 10
3 10
5 100
10 1
1 3
3 2
4 2
Sample Output
1
Constraints
Time limit: 1s; memory limit: 1024 KiB for each test case.
For of the data: .
For of the data: , , .
For of the data: , , .