Lobbying
Time limit1sMemory limit128 MB
Sum each lawmaker's donations made within 1000 days before the vote, then weight each no vote by 1/(1+D/10000) and add up both sides.
- Level
Easy3 of 10
- Topics
- Implementation, Math, Simulation, Array
- Solved
- No attempts yet
Problem
Major legislation is often accompanied by heavy lobbying, and lobbying can involve financial contributions to lawmakers. One proposed way to handle this is to let lawmakers accept donations from any source, but then use those donations to adjust the weight of their votes: if a lawmaker received strong financial support from an industry, a vote favoring that industry is downweighted accordingly. Here we compute the outcome of such weighted votes.
There is a single vote with two options: keep the status quo (which the health industry prefers), or adopt a new health care system. For each lawmaker you are given every financial contribution from the health industry, together with the day it was made. Only contributions made within the 1000 days before the vote count. If the vote is held on day , a contribution made on day is relevant only when .
Let be the total amount of relevant donations (in dollars) received by a lawmaker.
- If the lawmaker votes against the new system (the side favored by the health industry), the vote counts as votes against the new system.
- If the lawmaker votes for the new system, the vote counts as one full vote in favor.
Compute the total weighted number of votes for and against the new health care system.
Input
The first line contains the number of data sets. It is followed by data sets, each of the following form.
The first line of a data set contains three integers , , : is the number of lawmakers (), is the number of donations (), and is the day of the vote.
Then follow lines, each describing one donation with two integers , and a floating-point number : is the lawmaker who received the donation, is the day it was made, and is the amount. A donation is relevant only when .
Then follow lines; the -th of them contains a single character describing lawmaker 's vote. Y means the lawmaker voted for the reform (the new system), and N means the lawmaker voted against it.
Output
For each data set, print Data Set x: on a line by itself, where is the data set number (starting from 1). On the next line, print the total weighted number of votes for the new system and the total weighted number of votes against it, separated by a single space and each rounded to two decimal places. Separate consecutive data sets with one blank line.