Bailout Bonus
Time limit1sMemory limit128 MB
Given a list of bailed-out companies, a tax rate, and executives with company and bonus, sum the floor of the taxed fraction for executives at bailed companies.
- Level
Easy2 of 10
- Topics
- Implementation, Hash map, Math, Brute force
- Solved
- No attempts yet
Problem
To keep many financial companies from collapsing, the United States government (and several other governments) bailed them out by providing multi-billion-dollar emergency loans. Afterward, several of these companies went ahead and paid their executives large performance bonuses. After a public outcry, one measure taken to recover this money for the government was to impose a hefty 95% tax on the bonuses of employees at any company that had received bailout money. Your task is to compute how much money the government recovers.
You are given a list of the companies that received bailout money and the proposed tax rate (such as 95%), written as an integer (in this case, ). You are also given a list of executives, each with their company affiliation and proposed bonus. Every executive who works for a bailed-out company must pay back an percent fraction of their bonus, rounded down to the nearest integer. For simplicity, executives who work for companies that were not bailed out return none of their bonus.
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 four integers , , , and :
- is the total number of companies.
- is the number of those companies that were bailed out.
- is the total number of executives.
- is the tax rate, in percent.
The next line contains integers: the indices (each between and ) of the bailed-out companies. When , this line is empty. Then follow lines, each describing one executive. Each such line contains two integers and , where is the company that executive works for and is the bonus that executive received.
Output
For each data set, first print Data Set x: on a line by itself, where is the number of the data set (starting from ). On the next line, print the total amount of money the government recovers through taxes for that data set. Print a blank line between consecutive data sets.