首页 > 代码库 > bgty

bgty

#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a;
priority_queue<double,vector<double>,greater<double> >q;
int main()
{
//freopen("median.in","r",stdin);
//freopen("median.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=(n+1)/2;i++)
{
cin>>a;
q.push(a);
}
for(int i=1;i<=n/2;i++)
{
cin>>a;
if(a<=q.top())
{
q.pop();
q.push(a);
}
}
if(n%2!=0)
printf("%lf",q.top());
else
{
int t1=q.top();
q.pop();
printf("%lf",(t1+q.top())/2);
}
return 0;
}

bgty