#P2113. 看球泡妹子
看球泡妹子
Description
There are teams and matches in this World Cup. Xiao Ming, a male fan, likes watching matches, while Xiao Hong, a female fan, likes watching handsome guys. For each team, its strength in Xiao Ming’s view is , and the number of handsome guys in Xiao Hong’s view is .
Each match is between two teams with indices and . Xiao Ming thinks the excitement of a match equals the product of the two teams’ strengths, while Xiao Hong thinks it equals the sum of the two teams’ numbers of handsome guys.
Due to limited energy, they can watch at most matches. Of course, if they watch matches, they will always watch together. As a gentleman, Xiao Ming should compromise, so please write a program to find the maximum possible total excitement for Xiao Ming, subject to the constraint that Xiao Hong’s total excitement is at least .
Input Format
The first line contains four positive integers .
The second line contains positive integers separated by spaces.
The third line contains positive integers separated by spaces.
The next lines each contain two positive integers .
Output Format
Output a single line containing a single positive integer: the maximum total excitement that Xiao Ming can get. If it is impossible to satisfy Xiao Hong’s requirement, output -1.
4 3 2 5
2 2 1 3
1 1 1 2
1 2
2 3
3 4
7
Hint
Constraints
- For of the testdata, .
- For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号