QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#3270. 魔塔 OL

الإحصائيات

比特游戏公司最近发布了一款新游戏《魔塔 Online》,玩家可以操控勇士在游戏世界中与怪物进行搏斗。在游戏发布之初,魔塔里没有任何怪物,接下来将依次发生 $q$ 个事件,每个事件是以下三种之一:

  • + x y z a b:表示游戏发布了新版本,在游戏中新增了一只怪物。如果这是第一只新增的怪物,那么它的编号为 $1$;否则它的编号为最后一只新增的怪物的编号 $+1$。这只怪物位于魔塔的第 $x$ 层,它的等级为 $y$ 级,它的难度为 $z$。如果玩家选择击杀这只怪物,那么需要消耗 $a$ 点血量,在击杀成功后,玩家将得到一支可以恢复 $b$ 点血量的药剂并立即使用。
  • - k:表示游戏发布了新版本,编号为 $k$ 的怪物由于平衡性问题下架,它将不会出现在魔塔中。请注意:下架的怪物仍然保留它们的编号,未来新增的怪物不会复用被下架怪物的编号。
  • ? g l d:表示一个询问。某玩家希望击杀魔塔前 $g$ 层中所有等级不超过 $l$ 且难度不超过 $d$ 的怪物。玩家可以按照任意顺序去击杀这些怪物,登上新的一层不需要杀光当前层的所有怪物,且作战过程中不会受到别的怪物的干扰。你的任务是帮助该玩家计算出征前勇士的血量最少是多少。如果某个时刻勇士的血量是负数,那么游戏结束,你一定要防止这种情况的发生。

请写一个程序,依次回答每个询问。注意:每个询问只是玩家的一个思考,不会真正击杀任何一只怪物。

输入格式

输入的第一行包含一个整数 $q$,表示事件数。

接下来 $q$ 行,每行开头一个字符,随后是几个整数,依次描述每个事件。

输入数据保证 $1\leq q\leq 150000$,怪物总数不超过 $50000$,询问数量不超过 $50000$。

对于新增怪物操作,保证 $1\leq x,y,z\leq 10000$,且 $0\leq a,b\leq 10^9$。

对于下架怪物操作,保证操作合法,且每只怪物不会被重复下架。

对于询问,保证 $1\leq g,l,d\leq 10000$。

输出格式

对于每个询问,输出一行一个整数,即出征前勇士的血量的最小值。

样例数据

样例输入

10
+ 2 1 1 3 4
+ 1 2 2 2 5
? 2 2 2
+ 1 1 1 8 2
? 2 2 1
? 1 2 2
- 1
? 2 2 2
- 3
? 1 2 2

样例输出

2
7
5
5
2

数据范围与提示

  1. (3 分)怪物总数不超过 $8$,询问数量不超过 $8$。
  2. (7 分)怪物总数不超过 $5000$,询问数量不超过 $5000$。
  3. (10 分)药剂不会回血,且所有怪物的难度都是 $1$。即 $b=0$,且 $z=d=1$。
  4. (17 分)$1\leq x,y,z,g,l,d\leq 5$。
  5. (30 分)所有怪物的等级和难度都是 $1$。即 $y=z=l=d=1$。
  6. (33 分)无其他限制。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.