编程介的小学生 2019-08-12 21:50 采纳率: 20.5%
浏览 76

Kiki & Little Kiki的计算,用到的方法

Problem Description
Kiki is considered as a smart girl in HDU, many boys fall in love with her! Now, kiki will finish her education, and leave school, what a pity! One day, zjt meets a girl, who is like kiki very much, in the campus, and calls her little kiki. Now, little kiki want to design a container, which has two kinds of operation, push operation, and pop operation.
Push M:
Push the integer M into the container.
Pop M:
Find the maximal integer, which is not bigger than M, in the container. And pop it from the container. Specially, for all pop operations, M[i] is no bigger than M[i+1].
Although she is as smart as kiki, she still can't solve this problem! zjt is so busy, he let you to help little kiki to solve the problem. Can you solve the problem?

Input
The input contains one or more data sets. At first line of each input data set is an integer N (1<= N <= 100000) indicate the number of operations. Then N lines follows, each line contains a word (“Push” or “Pop”) and an integer M. The word “Push” means a push operation, while “Pop” means a pop operation. You may assume all the numbers in the input file will be in the range of 32-bit integer.

Output
For each pop operation, you should print the integer satisfy the condition. If there is no integer to pop, please print “No Element!”. Please print a blank line after each data set.

Sample Input
9
Push 10
Push 20
Pop 2
Pop 10
Push 5
Push 2
Pop 10
Pop 11
Pop 19
3
Push 2
Push 5
Pop 2

Sample Output
No Element!
10
5
2
No Element!

2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog