22160_PPMM

2022-5-16 18:21| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506162616100-Problem List-采集的数据-后羿采集器.html

Pro.ID

22160

Title

PPMM

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22160

AC

0

Submit

21

Ratio

0.00%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others)
  • 描述

    Suppose there is a queue, in which we could do some operations as follow:

    PUSH  X : Means that enqueue a number X ( -231 < X < 231 ) to the tail of the queue.

    POP : Means that dequeue a number from the head of the queue.

    MINUS : Means that form each number in the queue to its corresponding inverse number, viz. X = -X.

    MAX : Means that return the maximum number in the queue.

    Notice that for operations POP, MINUS and MAX, if it is no numbers current in the queue, just ignore them.

    Given a sequence of operations, then for each "MAX" operation, if this operation is not ignored, you should output the maximum value it returned.

    输入

    The first line of input there is one integer T ( T ≤ 10 ), giving the number of test cases in the input. For each test case, the first line contains a number N ( N ≤ 2000000 ), representing the quantity of operations. The following N lines give out the detail.

    输出

    Description

    Suppose there is a queue, in which we could do some operations as follow:

    PUSH  X : Means that enqueue a number X ( -231 < X < 231 ) to the tail of the queue.

    POP : Means that dequeue a number from the head of the queue.

    MINUS : Means that form each number in the queue to its corresponding inverse number, viz. X = -X.

    MAX : Means that return the maximum number in the queue.

    Notice that for operations POP, MINUS and MAX, if it is no numbers current in the queue, just ignore them.

    Given a sequence of operations, then for each "MAX" operation, if this operation is not ignored, you should output the maximum value it returned.

    Input

    The first line of input there is one integer T ( T ≤ 10 ), giving the number of test cases in the input. For each test case, the first line contains a number N ( N ≤ 2000000 ), representing the quantity of operations. The following N lines give out the detail.

    Output

    For each "MAX" operation not ignored, output the returned number in a line. Output a blank line between the test cases.

    Sample Input

    1
    6
    PUSH -2
    MINUS
    PUSH -1
    MAX
    POP
    MAX

    Sample Output

    2
    -1

    Source

    样例输入

    1
    6
    PUSH -2
    MINUS
    PUSH -1
    MAX
    POP
    MAX

    样例输出

    2
    -1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部