CF363D.Renting Bikes

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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?

一群 nn 名男学生决定骑自行车。由于他们中没有人拥有自行车,因此这些男生需要租用自行车。

租车网站向他们提供了 mm 辆自行车。不同自行车的租金各不相同,租用第 jj 辆自行车的费用为 pjp_j 卢布。

所有男生的公共预算总额为 aa 卢布。此外,每位男生还有自己的个人资金,其中第 ii 名男生有 bib_i 卢布的个人资金。公共预算可任意分配给任意男生使用,但每位男生的个人资金只能用于支付他自己所租自行车的费用。

每名男生最多只能租一辆自行车,且不允许将自己租来的自行车转借给他人。

问:最多有多少名男生能够骑上自行车?在让尽可能多的男生骑上自行车的前提下,他们总共至少需要花费多少个人资金?

输入格式

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 _b_1, _b_2, ..., b__n (1 ≤ b__i ≤ 104), 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 ≤ 109), where p__j is the price for renting the j-th bike.

输入的第一行包含三个整数 nn、mm 和 aa(1 ≤ n, m ≤ 1051 \leq n,\,m \leq 10^5;0 ≤ a ≤ 1090 \leq a \leq 10^9)。
第二行包含一个整数序列 b1, b2, ..., bnb_1,\,b_2,\,...,\,b_n(1 ≤ bi ≤ 1041 \leq b_i \leq 10^4),其中 bib_i 表示第 ii 个男孩的个人资金数额。
第三行包含一个整数序列 p1, p2, ..., pmp_1,\,p_2,\,...,\,p_m(1 ≤ pj ≤ 1091 \leq p_j \leq 10^9),其中 pjp_j 表示租用第 jj 辆自行车的价格。

输出格式

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.

输出两个整数 rr 和 ss,其中 rr 表示最多能租到自行车的男生人数,ss 表示租下 rr 辆自行车所需的最少总个人资金。如果学生们无法租到任何自行车,则 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.

在第一个样例中,两名学生都可以租一辆自行车。例如,他们可以将共用预算平均分配(每人 5 卢布)。此时,其中一人需自付 1 卢布,另一人需自付 2 卢布。他们总共花费了 3 卢布的个人资金。这种资金分配方式使得所花费的个人资金总额最小。

输入解题思路,AI测评打分。不知道怎么写?

首页