标签:
Description
Input
Output
Sample Input
input | output |
---|---|
4 3 6 4 5 |
4.5 |
这道题 你会发现存不下,只能存一半
然后瞎搞搞,就出来了
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define maxn 100001 const int inf=0x7fffffff; //无限大 priority_queue<unsigned int> q; int main() { int n; while(cin>>n) { while(!q.empty()) q.pop(); unsigned int x; int kill=n/2+1; unsigned int fuck; for(int i=0;i<kill;i++) { cin>>x; q.push(x); } for(int i=kill;i<n;i++) { cin>>x; fuck=q.top(); if(x<fuck) { q.pop(); q.push(x); } } if(n%2==0) { unsigned int a=q.top(); q.pop(); unsigned int b=q.top(); printf("%.1lf\n",(a+b)/2.0); } else { unsigned int a=q.top(); printf("%.1lf\n",a*1.0); } } return 0; }
poj 2623 Sequence Median 堆的灵活运用
标签:
原文地址:http://www.cnblogs.com/qscqesze/p/4245724.html