304173: CF799C. Fountains
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Fountains
题意翻译
## 题目描述 Arkady想要建 $2$ 座喷泉,他有 $n$ 座可以选的喷泉,$c$ 个金币和 $d$个钻石, 每座喷泉可且仅可用金币或钻石一种货币来买,金币和钻石也不能以任何方式转化。现在要使两座喷泉美丽值总和最大且Arkady能买得起,求出最大美丽值。 ## 输入格式 第一行 $3$ 个数,$n$ ,$c$,$d$ $(2<=n<=100000,0<=c,d<=100000)$,分别表示喷泉的数量,Arkady金币和钻石的个数。 接下来 $n$ 行描述喷泉,每行 $2$ 个正整数,$b_i$,$p_i$ $(1<=b_i,p_i<=100000)$,还有一个字母 "C" 或 "D",分别表示第 $i$ 座喷泉的美丽值,价格,还有买喷泉所需要的货币类型,"C"是金币,"D"是钻石。 ## 输出格式 输出一行一个正整数,即两座喷泉的最大美丽值总和。题目描述
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.输入输出格式
输入格式
The first line contains three integers $ n $ , $ c $ and $ d $ ( $ 2<=n<=100000 $ , $ 0<=c,d<=100000 $ ) — 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}<=100000 $ ) — 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.
输出格式
Print the maximum total beauty of exactly two fountains Arkady can build. If he can't build two fountains, print 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