PROGRAMMING:Election intervention
Given an election with voting districts and majority rule, how many voters have to be bribed such that our party wins a majority of districts?
In elections with constituencies and majority rule, how many voters should we bribe to make our party win the majority of constituencies?
Solution:For each district simulate how many votes are needed to achieve majority by taking one vote at a time from the currently highest voted party and adding it to our total.Greedily take the districts that need the fewest votes until our party has won the majority of districts. Can be sped up by taking enough votes at a time from the current ly highest voted parties until they are equal to the next highest party. Repeat until our party has the majority of votes.
Solution: for each constituency, simulate how many votes it takes to get a majority, choose one vote from the party that currently has the most votes, and then add it to our total. Before our party wins the majority of constituencies, greedily choose those constituencies that need the least votes. You can speed up voting by getting enough votes from the party with the highest number of votes at one time until they are in line with the party with the second highest number of votes. Repeat, until our party gets a majority.
###Input format:
The input considerations of:
• One line with two integers w and p ( 2 ≤ w,p ≤ 1000 ), the number of districts and the number of parties running in the election. The parties are numbered 1 to p and the ICPC is party 1.
One row, two integers W and P (2 ≤ W, P ≤ 1000), the number of constituencies and the number of parties. Both parties number from 1 to P, ICPC is the first party.
• w lines, each with p integers v 1 ,...,v p ( 0 ≤ v i ≤ 1000 for each i ) giving the projected results for a district. vi denotes the number of votes that will be cast for party i.
Each row has p integers V1,..., VP (C0 ≤ VI ≤ 1000) gives the projection result of a region. VI is the number of votes to be cast for one party.
It is guaranteed that there is at least one voter in each district, i.e. the sum of all v i per district will always be at least one.
Ensure that there is at least one voter in each region, that is, the sum of all VI in each region is at least one.
###Output format:
Output the minimum number of voters that have to be bribed in order for the ICPC to win a majority of the seats in the council.
Output the minimum number of voters that must be bribed in order for ICPC to win a majority in the Committee.
###Input sample 1:
```in
3 3
0 2 2
1 2 3
0 2 3
```
###Output sample 1:
```out
four
```
###Input sample 2:
```in
2 4
0 1 2 9
1 0 0 0
```
###Output sample 2:
```out
five
```
###Input sample 3:
```in
3 3
1 0 0
0 1000 0
0 9 5
```
###Output sample 3:
```out
six
```
answer:If there is no answer, please comment
In elections with constituencies and majority rule, how many voters should we bribe to make our party win the majority of constituencies?
Solution:For each district simulate how many votes are needed to achieve majority by taking one vote at a time from the currently highest voted party and adding it to our total.Greedily take the districts that need the fewest votes until our party has won the majority of districts. Can be sped up by taking enough votes at a time from the current ly highest voted parties until they are equal to the next highest party. Repeat until our party has the majority of votes.
Solution: for each constituency, simulate how many votes it takes to get a majority, choose one vote from the party that currently has the most votes, and then add it to our total. Before our party wins the majority of constituencies, greedily choose those constituencies that need the least votes. You can speed up voting by getting enough votes from the party with the highest number of votes at one time until they are in line with the party with the second highest number of votes. Repeat, until our party gets a majority.
###Input format:
The input considerations of:
• One line with two integers w and p ( 2 ≤ w,p ≤ 1000 ), the number of districts and the number of parties running in the election. The parties are numbered 1 to p and the ICPC is party 1.
One row, two integers W and P (2 ≤ W, P ≤ 1000), the number of constituencies and the number of parties. Both parties number from 1 to P, ICPC is the first party.
• w lines, each with p integers v 1 ,...,v p ( 0 ≤ v i ≤ 1000 for each i ) giving the projected results for a district. vi denotes the number of votes that will be cast for party i.
Each row has p integers V1,..., VP (C0 ≤ VI ≤ 1000) gives the projection result of a region. VI is the number of votes to be cast for one party.
It is guaranteed that there is at least one voter in each district, i.e. the sum of all v i per district will always be at least one.
Ensure that there is at least one voter in each region, that is, the sum of all VI in each region is at least one.
###Output format:
Output the minimum number of voters that have to be bribed in order for the ICPC to win a majority of the seats in the council.
Output the minimum number of voters that must be bribed in order for ICPC to win a majority in the Committee.
###Input sample 1:
```in
3 3
0 2 2
1 2 3
0 2 3
```
###Output sample 1:
```out
four
```
###Input sample 2:
```in
2 4
0 1 2 9
1 0 0 0
```
###Output sample 2:
```out
five
```
###Input sample 3:
```in
3 3
1 0 0
0 1000 0
0 9 5
```
###Output sample 3:
```out
six
```
answer:If there is no answer, please comment