307771: CF1413D. Shurikens
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Shurikens
题意翻译
有一家商店开始出售 $n$ 个 karry 的手办,第 $i$ 个 karry 的手办可以用 $i$ 个 $\text{ryu}$ 买到。($\text{ryu}$ 是一种货币单位) 现在有 $2n$ 次操作: $\text{+}$:表示在柜台上摆放一个 karry。 $\text{- x}$:表示被买走的 karry 需要 $x$ 个 $\text{ryu}$。如果柜台上摆放了很多个 karry,人们永远只会买最便宜的那一个。 要求根据这 $2n$ 次操作,给出 **任意一种** 合法的摆放 karry 手办的顺序。题目描述
Tenten runs a weapon shop for ninjas. Today she is willing to sell $ n $ shurikens which cost $ 1 $ , $ 2 $ , ..., $ n $ ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shuriken (from the available shurikens) on the showcase, and sometimes a ninja comes in and buys a shuriken from the showcase. Since ninjas are thrifty, they always buy the cheapest shuriken from the showcase. Tenten keeps a record for all events, and she ends up with a list of the following types of records: - + means that she placed another shuriken on the showcase; - - x means that the shuriken of price $ x $ was bought. Today was a lucky day, and all shurikens were bought. Now Tenten wonders if her list is consistent, and what could be a possible order of placing the shurikens on the showcase. Help her to find this out!输入输出格式
输入格式
The first line contains the only integer $ n $ ( $ 1\leq n\leq 10^5 $ ) standing for the number of shurikens. The following $ 2n $ lines describe the events in the format described above. It's guaranteed that there are exactly $ n $ events of the first type, and each price from $ 1 $ to $ n $ occurs exactly once in the events of the second type.
输出格式
If the list is consistent, print "YES". Otherwise (that is, if the list is contradictory and there is no valid order of shurikens placement), print "NO". In the first case the second line must contain $ n $ space-separated integers denoting the prices of shurikens in order they were placed. If there are multiple answers, print any.
输入输出样例
输入样例 #1
4
+
+
- 2
+
- 3
+
- 1
- 4
输出样例 #1
YES
4 2 3 1
输入样例 #2
1
- 1
+
输出样例 #2
NO
输入样例 #3
3
+
+
+
- 2
- 1
- 3
输出样例 #3
NO