PAT甲级练习1057. Stack (30)-未完成
来源:互联网 发布:php unlink删除文件 编辑:程序博客网 时间:2024/05/14 17:48
1057. Stack (30)
Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and Pop (deleting the top element). Now you are supposed to implement a stack with an extra operation: PeekMedian -- return the median value of all the elements in the stack. With N elements, the median value is defined to be the (N/2)-th smallest element if N is even, or ((N+1)/2)-th if N is odd.
Input Specification:
Each input file contains one test case. For each case, the first line contains a positive integer N (<= 105). Then N lines follow, each contains a command in one of the following 3 formats:
Push keyPop
PeekMedian
where key is a positive integer no more than 105.
Output Specification:
For each Push command, insert key into the stack and output nothing. For each Pop or PeekMedian command, print in a line the corresponding returned value. If the command is invalid, print "Invalid" instead.
Sample Input:17PopPeekMedianPush 3PeekMedianPush 2PeekMedianPush 1PeekMedianPopPopPush 5Push 4PeekMedianPopPopPopPopSample Output:
InvalidInvalid322124453Invalid
- PAT甲级练习1057. Stack (30)-未完成
- 【PAT甲级】1057. Stack (30)
- PAT甲级1057. Stack (30)
- PAT 甲级 1057. Stack (30)
- PAT甲级练习1026. Table Tennis (30)-未完成
- 未完成-PAT甲级练习1075. PAT Judge (25)
- 未完成-PAT甲级练习1066. Root of AVL Tree (25)
- 1057. Stack (30)-PAT甲级真题(树状数组)
- PAT甲级练习1004. Counting Leaves (30)
- PAT甲级练习1022. Digital Library (30)
- PAT甲级练习1030. Travel Plan (30)
- PAT甲级练习1049. Counting Ones (30)
- PAT甲级练习1072. Gas Station (30)
- PAT甲级练习1080. Graduate Admission (30)
- PAT 甲级练习 1001
- PAT 甲级练习 1002
- 1057. Stack (30)-PAT
- pat 1057. Stack (30)
- Java中 equals() 和 == 的区别
- CSS基础知识(1)
- 几种高并发下写的处理策略
- pat 1012. The Best Rank (25)
- 【半年总结】—一切都是最好的安排
- PAT甲级练习1057. Stack (30)-未完成
- Tomcat启动时卡在“INFO: Deploying web application directory ......”的解决方法
- 自我规划系列:你离心想事成只差一个计划 | 进击 .
- 一切轻量级WEB服务器推荐
- 面向对象五大原则
- 线程同步机制的区别与比较及进程通信方法
- springMVC <spring:message>国际化
- WordPress新用户注册时提示“您的密码重设链接无效”
- C#四舍五入、上取整、下取整