CF799C.Fountains
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either in coins or diamonds. No money changes between the types are allowed.
Help Arkady to find two fountains with maximum total beauty so that he can buy both at the same time.
阿尔卡季经常玩《花园景观》(Gardenscapes)。阿尔卡季想要建造两座新的喷泉。目前共有 n 座可选喷泉,每座喷泉的美观度和价格均已知。游戏中有两种货币:金币和钻石,因此每座喷泉的价格要么以金币计,要么以钻石计。两种货币之间不允许相互兑换。
请帮助阿尔卡季找出两座喷泉,使得它们的总美观度最大,且他能同时购买这两座喷泉。
输入格式
The first line contains three integers n, c and d (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100 000) — the number of fountains, the number of coins and diamonds Arkady has.
The next n lines describe fountains. Each of these lines contain two integers b__i and p__i (1 ≤ b__i, p__i ≤ 100 000) — the beauty and the cost of the i-th fountain, and then a letter "C" or "D", describing in which type of money is the cost of fountain i: in coins or in diamonds, respectively.
第一行包含三个整数 n、c 和 d(2 ≤ n ≤ 100000,0 ≤ c,d ≤ 100000)——分别表示喷泉的数量、Arkady 拥有的硬币数量和钻石数量。
接下来的 n 行描述喷泉。每行包含两个整数 bi 和 pi(1 ≤ bi,pi ≤ 100000)——分别为第 i 个喷泉的美观度和价格,随后是一个字母 "C" 或 "D",分别表示第 i 个喷泉的价格是用硬币还是钻石支付。
输出格式
Print the maximum total beauty of exactly two fountains Arkady can build. If he can't build two fountains, print 0.
输出 Arkady 恰好建造两座喷泉所能获得的最大总美观度。如果他无法建造两座喷泉,则输出 0。
输入输出样例
输入#1
3 7 6 10 8 C 4 3 C 5 6 D
输出#1
9
输入#2
2 4 5 2 5 C 2 1 D
输出#2
0
输入#3
3 10 10 5 5 C 5 5 C 10 11 D
输出#3
10
说明/提示
In the first example Arkady should build the second fountain with beauty 4, which costs 3 coins. The first fountain he can't build because he don't have enough coins. Also Arkady should build the third fountain with beauty 5 which costs 6 diamonds. Thus the total beauty of built fountains is 9.
In the second example there are two fountains, but Arkady can't build both of them, because he needs 5 coins for the first fountain, and Arkady has only 4 coins.
在第一个例子中,阿尔卡季应当建造第二座喷泉,其美观度为 4,花费 3 枚金币。他无法建造第一座喷泉,因为金币不足。此外,阿尔卡季还应建造第三座喷泉,其美观度为 5,花费 6 颗钻石。因此,所建造喷泉的总美观度为 9。
在第二个例子中,共有两座喷泉,但阿尔卡季无法同时建造它们,因为第一座喷泉需要 5 枚金币,而阿尔卡季仅有 4 枚金币。
输入解题思路,AI测评打分。不知道怎么写?