CF363D.Renting Bikes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A group of nn schoolboys decided to ride bikes. As nobody of them has a bike, the boys need to rent them.

The renting site offered them mm bikes. The renting price is different for different bikes, renting the jj -th bike costs pjp_{j} rubles.

In total, the boys' shared budget is aa rubles. Besides, each of them has his own personal money, the ii -th boy has bib_{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 nn , mm and aa ( 1<=n,m<=1051<=n,m<=10^{5} ; 0<=a<=1090<=a<=10^{9} ). The second line contains the sequence of integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 1<=bi<=1041<=b_{i}<=10^{4} ), where bib_{i} is the amount of the ii -th boy's personal money. The third line contains the sequence of integers p1,p2,...,pmp_{1},p_{2},...,p_{m} ( 1<=pj<=1091<=p_{j}<=10^{9} ), where pjp_{j} is the price for renting the jj -th bike.

输出格式

Print two integers rr and ss , where rr is the maximum number of schoolboys that can rent a bike and ss is the minimum total personal money needed to rent rr bikes. If the schoolchildren cannot rent any bikes, then r=s=0r=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.

首页