5894: 租用自行车

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

D. 租用自行车
每次测试的时间限制
1 秒
每个测试的内存限制
256 兆字节
输入
标准输入
输出
标准输出
一群n个男生决定骑自行车。由于他们中没有人有自行车,男孩们需要租一辆自行车。
租赁网站为他们提供了m自行车。不同自行车的租赁价格不同,租用 j 自行车的费用为 pj 卢布。
总的来说,男孩们的共同预算是卢布。此外,他们每个人都有自己的个人钱,第 i 个男孩有 bi 个人卢布。共享预算可以任意花在任何学童身上,但每个男孩的个人钱只能用于租用这个男孩的自行车。
每个男孩最多可以租一辆自行车,不能把自行车送给别人。
最多有多少男生可以骑自行车?他们总共需要花费多少最低的个人钱才能让尽可能多的学童骑自行车?

输入
输入的第一行包含三个整数 n、m 和 a (1≤nm≤1050≤a≤109)。第二行包含整数序列 b 1,b 2,...,b n (1b i≤104),其中 b i 是第 i 个男孩的个人钱的金额。第三行包含整数序列 p 1,p 2,...,p m (1p j≤109),其中 p j 是租用 j 辆自行车的价格。
输出
打印两个整数 r 和 s,其中 r 是可以租用自行车的最大男生数量,s 是租用 r 自行车所需的最小个人总资金。如果学童不能租任何自行车,那么r=s=0
例子
输入
2 2 10
5 5
7 6
输出
2 3
输入
4 5 2
8 1 1 2
6 3 7 5 2
输出
3 8
注意
在第一个样本中,两个学童都可以租一辆自行车。例如,他们可以将共享预算分成两半(每人 5 卢布)。在这种情况下,其中一个必须从个人资金中支付 1 卢布,另一个必须从个人资金中支付 2 卢布。他们总共花费了 3 卢布的个人钱。这种货币分配方式最大限度地减少了花费的个人资金的数量。
D. Renting Bikes
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
A group of n schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.
The renting site offered them m bikes. The renting price is different for different bikes, renting the j-th bike costs pj rubles.
In total, the boys' shared budget is a rubles. Besides, each of them has his own personal money, the i-th boy has bi personal rubles. The shared budget can be spent on any schoolchildren arbitrarily, but each boy's personal money can be spent on renting only this boy's bike.
Each boy can rent at most one bike, one cannot give his bike to somebody else.
What maximum number of schoolboys will be able to ride bikes? What minimum sum of personal money will they have to spend in total to let as many schoolchildren ride bikes as possible?

Input
The first line of the input contains three integers n, m and a (1≤n,m≤105; 0≤a≤109). The second line contains the sequence of integers b1,b2,...,bn (1≤bi≤104), where bi is the amount of the i-th boy's personal money. The third line contains the sequence of integers p1,p2,...,pm (1≤pj≤109), where pj is the price for renting the j-th bike.
Output
Print two integers r and s, where r is the maximum number of schoolboys that can rent a bike and s is the minimum total personal money needed to rent r bikes. If the schoolchildren cannot rent any bikes, then r=s=0.
Examples
Input
2 2 10
5 5
7 6
Output
2 3
Input
4 5 2
8 1 1 2
6 3 7 5 2
Output
3 8
Note
In the first sample both schoolchildren can rent a bike. For instance, they can split the shared budget in half (5 rubles each). In this case one of them will have to pay 1 ruble from the personal money and the other one will have to pay 2 rubles from the personal money. In total, they spend 3 rubles of their personal money. This way of distribution of money minimizes the amount of spent personal money.

输入样例 复制


输出样例 复制


分类标签