A10902 | Fountains
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
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
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted