#P4307. [JSOI2009] 球队收益 / 球队预算
[JSOI2009] 球队收益 / 球队预算
Description
In a basketball league, there are teams. A team's expenditure is related to its numbers of wins and losses. Specifically, the season's total expenditure of the -th team is . (The more you win, the more bonuses you pay to the players.)
Now the season is halfway through. Each team has achieved wins and losses. There are still games to be played. Find the minimum total expenditure across all teams in the league.
Input Format
The first line contains and .
Each of the next lines contains integers .
Each of the next lines contains two integers , , meaning the -th team and the -th team will play one game. Note that there may be multiple games between the same pair of teams.
Output Format
Print one integer representing the minimum total expenditure.
3 3
1 0 2 1
1 1 10 1
0 1 3 3
1 2
2 3
3 1
43
Hint
For of the testdata, .
For of the testdata, $2 \le n \le 5000,0 \le m \le 1000,0 \le D_i \le C_i \le 10,0 \le a_i,b_i \le 50$.
Translated by ChatGPT 5
京公网安备 11011102002149号