#P2113. 看球泡妹子

看球泡妹子

Description

There are nn teams and mm 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 aia_i, and the number of handsome guys in Xiao Hong’s view is bib_i.

Each match is between two teams with indices pip_i and qiq_i. 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 kk 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 cc.

Input Format

The first line contains four positive integers n,m,k,cn, m, k, c.

The second line contains nn positive integers aia_i separated by spaces.

The third line contains nn positive integers bib_i separated by spaces.

The next mm lines each contain two positive integers pi,qip_i, q_i.

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 20%20\% of the testdata, 1n,m,k51 \le n, m, k \le 5.
  • For 100%100\% of the testdata, 1n1001 \le n \le 100, 1km1001 \le k \le m \le 100, 1ai,bi101 \le a_i, b_i \le 10, 1c1031 \le c \le 10^3.

Translated by ChatGPT 5