A7857 | Seller Bob
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Last year Bob earned by selling memory sticks. During each of $n$ days of his work one of the two following events took place:
- A customer came to Bob and asked to sell him a $2^{x}$ MB memory stick. If Bob had such a stick, he sold it and got $2^{x}$ berllars.
- Bob won some programming competition and got a $2^{x}$ MB memory stick as a prize. Bob could choose whether to present this memory stick to one of his friends, or keep it.
Bob never kept more than one memory stick, as he feared to mix up their capacities, and deceive a customer unintentionally. It is also known that for each memory stick capacity there was at most one customer, who wanted to buy that memory stick. Now, knowing all the customers' demands and all the prizes won at programming competitions during the last $n$ days, Bob wants to know, how much money he could have earned, if he had acted optimally.
- A customer came to Bob and asked to sell him a $2^{x}$ MB memory stick. If Bob had such a stick, he sold it and got $2^{x}$ berllars.
- Bob won some programming competition and got a $2^{x}$ MB memory stick as a prize. Bob could choose whether to present this memory stick to one of his friends, or keep it.
Bob never kept more than one memory stick, as he feared to mix up their capacities, and deceive a customer unintentionally. It is also known that for each memory stick capacity there was at most one customer, who wanted to buy that memory stick. Now, knowing all the customers' demands and all the prizes won at programming competitions during the last $n$ days, Bob wants to know, how much money he could have earned, if he had acted optimally.
输入格式
The first input line contains number $n$ ( $1<=n<=5000$ ) — amount of Bob's working days. The following $n$ lines contain the description of the days. Line sell x stands for a day when a customer came to Bob to buy a $2^{x}$ MB memory stick ( $0<=x<=2000$ ). It's guaranteed that for each $x$ there is not more than one line sell x. Line win x stands for a day when Bob won a $2^{x}$ MB memory stick ( $0<=x<=2000$ ).
输出格式
Output the maximum possible earnings for Bob in berllars, that he would have had if he had known all the events beforehand. Don't forget, please, that Bob can't keep more than one memory stick at a time.
输入输出样例
输入 #1
7 win 10 win 5 win 3 sell 5 sell 3 win 10 sell 10
输出 #1
1056
输入 #2
3 win 5 sell 6 sell 4
输出 #2
0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted