2009_10-5_Practice1 E
来源:互联网 发布:阐教 截教 知乎 编辑:程序博客网 时间:2024/04/29 08:54
<!--@page { margin: 2cm }P { margin-bottom: 0.21cm }-->
SpecialContainer
TimeLimit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K(Java/Others)
Designa container, which has two kinds of operation, push and pop.
Push:You should push the given number into the container.
Pop:Please find the middle number of the container. If these is n numbersin container, it will be the (n+1)/2-th num when sort increased. Thenpop the number.
Input
Theinput contains one or more data sets. At first line of each inputdata set is an integer N (1<= N <= 100000) indicate the numberof operations.
ThenN lines follows, each line contains a number (0 or 1). "0"means a push operation, it's followed by an integer E. "1"means a pop operation.
Youmay assume all the numbers in the input file will be in the range of32-bit integer.
Output
Foreach pop operation, you should print the integer popped. Please print"No Element!", if there is no number to pop. Please print ablank line after each data set.
SampleInput
9
010
0-10
05
1
1
02
1
1
1
3
02
01
1
SampleOutput
5
-10
2
10
NoElement!
1
1.用树状数组的方法,因为只有N次操作,但是不知道操作数范围,所以要先离散化一下,那么就要先记录;
2.有两种操作:push pop 在pop的时候怎样找到位置在(n+1)/2的数呢。。。肯定不能排序 位置在那个地方的数的特点是前面存在一定数量比他小的,因为是实时的操作,那么用树状数组记录某个
后记:我觉得这道题很强大。
首先刚开始看的时候我没有想到,后来听某牛说用树状数组可以解,就试着想了下
- 2009_10-5_Practice1 E
- 2009_10-5_Practice1 C
- 工作总结_10
- FPGA_Embedded_9_9~9_10
- 今日总结11_10
- Linux文件系统笔记_10
- 黑马程序员_10 UDP
- windows8.1_10.17
- 黑马程序员_10多线程
- ?[C++_10]RTTI
- 总结_10-28
- c++_10: 异常处理
- c++_10: string类
- 8_10上午复习
- 安卓基础_10
- Java学习笔记_10
- Qt笔记_10
- JAVA知识_10
- irrlicht3d游戏引擎
- 程序
- 毛主席语录
- Supporting a Printer-Friendly Page Button (Part I)
- Irrlicht3d编程的两个常见错误解决
- 2009_10-5_Practice1 E
- 2009_10-5_Practice1 C
- irrlicht中的数据类型
- 房市最佳购买时点在11月中至春节之前
- 怒揭黑莓市场黑幕,还消费者公道
- 网络技术中的tcp/ip协议如何学习,才能理解的更深?
- 传文件选MSN还是QQ? 揭秘IM传输工作原理
- [Linux学习笔记]目录、路径、文件、目录常用命令
- 永州阳明山林家铺子大酒店