poj 2388 Who's in the Middle
来源:互联网 发布:page 知页还是面 编辑:程序博客网 时间:2024/05/16 00:51
原题链接:http://poj.org/problem?id=2388
数据很水,可用堆,可快排。
具体实现如下:
#include<stdio.h>#include<stdlib.h>#include<string.h>#define Max_N 100002int heap[Max_N],sz;void push(int x){int i=sz++;while(i>0){int p=(i-1)>>1;if(heap[p]<=x) break;heap[i]=heap[p];i=p;}heap[i]=x;}int pop(){int x,i=0,ret=heap[0];x=heap[--sz];while((i<<1)+1<sz){int a=(i<<1)+1,b=(i<<1)+2;if(b<sz && heap[a]>heap[b]) a=b;if(heap[a]>=x) break;heap[i]=heap[a];i=a;}heap[i]=x;return ret;}int main(){int i,n,ret;while(EOF!=scanf("%d",&n)){sz=0;for(i=0;i<n;i++){scanf("%d",&ret);push(ret);}for(i=0; i < n>>1;i++) pop();printf("%d\n",pop());}return 0;}
0 0
- POJ--2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ-2388 who's in the middle
- poj-2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- Poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- poj 2388 Who's in the Middle
- POJ-2388-Who's in the Middle
- poj 2388 Who's in the Middle
- POJ 2388 Who's in the Middle
- poj 2388 Who's in the Middle
- Who's in the Middle(poj 2388)
- POJ 2388:Who's in the Middle
- java根据jar包反编译后修改再打包回jar的做法
- QlikView处理数据
- javaweb监听器
- iOS钥匙串
- javascript正则表达式修饰符之multiline(/m)的使用
- poj 2388 Who's in the Middle
- JS实现表格数据各种搜索功能
- HDU 1233 还是畅通工程 (MST)
- Leetcode_53_Maximum Subarray
- java jinfo命令(Java Configuration Info)
- 媒体服务频道访问控制
- poj 2761 Feed the dogs
- HDU 1875 畅通工程再续
- Deepin禁用usb声卡