301918: CF363D. Renting Bikes

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Renting Bikes

题意翻译

一组n个学生要租车,一共有m辆车,每辆价格不同,为p[1],p[2]……p[m]卢布。他们有a卢布共有的钱,每人还有b[1],b[2]……b[n]卢布自己的钱。自己的钱只能自己用,共有的钱可以分给任何人用,且一个人只能租一辆车。求出最多能有多少人租到车,以及各人自己的钱总和最小多少(在最多人租到车的前提下) 第一行输入n,m,a,第二行输入b[1],b[2]……b[n],第三行输入p[1],p[2]……p[m]。 输出两个数:最多能有多少人租到车,以及各人自己的钱总和最小多少(在最多人租到车的前提下) 翻译提供者:永恒之光

题目描述

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 $ p_{j} $ rubles. In total, the boys' shared budget is $ a $ rubles. Besides, each of them has his own personal money, the $ i $ -th boy has $ b_{i} $ 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?

输入输出格式

输入格式


The first line of the input contains three integers $ n $ , $ m $ and $ a $ ( $ 1<=n,m<=10^{5} $ ; $ 0<=a<=10^{9} $ ). The second line contains the sequence of integers $ b_{1},b_{2},...,b_{n} $ ( $ 1<=b_{i}<=10^{4} $ ), where $ b_{i} $ is the amount of the $ i $ -th boy's personal money. The third line contains the sequence of integers $ p_{1},p_{2},...,p_{m} $ ( $ 1<=p_{j}<=10^{9} $ ), where $ p_{j} $ is the price for renting the $ j $ -th bike.

输出格式


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 $ .

输入输出样例

输入样例 #1

2 2 10
5 5
7 6

输出样例 #1

2 3

输入样例 #2

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

输出样例 #2

3 8

说明

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.

Input

题意翻译

一组n个学生要租车,一共有m辆车,每辆价格不同,为p[1],p[2]……p[m]卢布。他们有a卢布共有的钱,每人还有b[1],b[2]……b[n]卢布自己的钱。自己的钱只能自己用,共有的钱可以分给任何人用,且一个人只能租一辆车。求出最多能有多少人租到车,以及各人自己的钱总和最小多少(在最多人租到车的前提下) 第一行输入n,m,a,第二行输入b[1],b[2]……b[n],第三行输入p[1],p[2]……p[m]。 输出两个数:最多能有多少人租到车,以及各人自己的钱总和最小多少(在最多人租到车的前提下) 翻译提供者:永恒之光

加入题单

上一题 下一题 算法标签: