#P4307. [JSOI2009] 球队收益 / 球队预算

    ID: 3247 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2009各省省选江苏图的建立,建图费用流

[JSOI2009] 球队收益 / 球队预算

Description

In a basketball league, there are nn teams. A team's expenditure is related to its numbers of wins and losses. Specifically, the season's total expenditure of the ii-th team is Ci×x2+Di×y2,DiCiC_i\times x^2+D_i \times y^2,D_i \le C_i. (The more you win, the more bonuses you pay to the players.)

Now the season is halfway through. Each team has achieved aia_i wins and bib_i losses. There are still mm games to be played. Find the minimum total expenditure across all teams in the league.

Input Format

The first line contains nn and mm.

Each of the next nn lines contains 44 integers ai,bi,Ci,Dia_i,b_i,C_i,D_i.

Each of the next mm lines contains two integers ss, tt, meaning the ss-th team and the tt-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 20%20\% of the testdata, 2n10,0m202 \le n \le 10,0 \le m \le 20.

For 100%100\% 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