当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
Byteasar is a programmer who works on a revolutionary text editor. In the editor there are two types of operations: one type allows to edit text in the editor, and the other type allows to undopreviously performed operations. One of the innovative features of this editor is a multilevel undo operation. It works as follows. We say that a text editing operation is an operation of level 0. Anundo operation of level I (for i=1,2…) undoes the last operation of level at most i-1 which is not undone. For instance, an undo operation of level 1 can undo only editing operations, and an undo operation of level 2 can undo editing operations as well as undo operations of level 1 (but no undo operations of greater levels).
The first line of the input contains a positive integer n, specifying the number of operations performed by Byteasar. The next n lines contain descriptions of operations, one per line, each being an integer Ai(-n<=Ai<=N,Ai<>0) ). If Ai>0, then it specifies an editing operation which modifies the editor state to Ai. If Ai<0, then it specifies an undo operation of level -Ai. You can assume that for every undo operation there will be some operation in the state active of smaller level to undo.
Your program should output n lines. The i-th line should contain one integer specifying the editor state after performing the first i operations from the input.
11 1 2 5 -1 -1 -3 4 -2 -1 -1 1
1 2 5 2 1 2 4 2 1 0 1
N<=300 000
| 时间上限 | 内存上限 |
| 10000 MS | 512 MB |