3759. 打工人的假期

The working class person's vacation

time limit per test: 1s

memory limit per test:256MB


Description:

During the holidays, everyone goes out for travel, except for the working class who doesn't have this privilege. While others are resting, they continue to work tirelessly for their bosses. If caught slacking off, they may even have their wages deducted (╥﹏╥).

Today, a working class person encountered a problem. In their team, there are  members with numbers ranging fromto. Each member has their own speed and efficiency. The working class person wants to know the maximum team performance value formed by at most  members. Due to the possibility of a large answer, you only need to output the result modulo .


The team performance value is defined as the sum of speeds of all members multiplied by the minimum efficiency value among them.


In the future, everyone will surely have a starting salary of at least 20,000, and won't have to worry about wage deductions like the working class person (^▽^).


Input Format:

The first line contains an integer .


The second line containsintegers separated by spaces: , where  represents the working speed of member with the ID .


The third line containsintegers separated by spaces: , where  represents the working efficiency of member with the ID .


The last line contains an integer , representing the maximum number of members required.


Output Format:

Output an integer in one line, representing the final result after taking the modulo.


Input Case#1

6 
2 10 3 1 5 8
5 4 3 9 7 2
2


Output Case#1

60


Input Case#2

6
2 10 3 1 5 8
5 4 3 9 7 2
4


Output Case#2

72


Note

Consider the first test case: Select members 2 (speed = 10, efficiency = 4) and 5 (speed = 5, efficiency = 7). Their team performance value is.




打工人的假期

时间限制: 1s

内存限制:256MB


题目描述

假期到了,大家都出去旅游了。但打工人却没有这个待遇,在大家休息的时候,还在不停地给老板打工。要是被老板发现偷懒的话,还会被扣工资(╥﹏╥)。 今天,打工人遇到一个问题,在打工人的团队里有编号为  到  的  个成员。每位成员都有自己的工作速度和效率。打工人想要知道由最多  个成员组成的最大团队表现值 ,由于答案可能很大,你只需要输出对  取余后的结果即可。


团队表现值的定义为:一个团队中所有成员工作速度的和乘以他们效率值中的最小值


大家以后肯定都是月薪2w起步,不用像打工人一样担心被扣工资(^▽^).


输入格式

输入第一行是一个整数 


第二行包含  个整数,用空格分隔:代表编号为  的成员的工作速度。


第三行包含  个整数,用空格分隔:代表编号为  的成员的工作效率。


最后一行一个整数 ,代表最多需要  个成员。


输出格式

在一行中输出一个整数,表示取余后的最终结果。


输入样例#1

6
2 10 3 1 5 8
5 4 3 9 7 2
2


输出样例#1

60


输入样例#2

6
2 10 3 1 5 8
5 4 3 9 7 2
4


输出样例#2

72


备注

考虑第一个测试用例: 选择成员 2(speed=10 , efficiency=4)和成员 5(speed=5 , efficiency=7)。他们的团队表现值为 

难度等级: 0
总通过次数: 7
总提交次数: 82