0
点赞
收藏
分享

微信扫一扫

Ignatius and the Princess IV HDU - 1029


​​Ignatius and the Princess IV HDU - 1029​​​
题意:
给你一个奇数n,然后给你n个数,让你张一个特殊的数在n个数中,这个数在n个数中至少出现了半数以上。输出这个数。
半数以上,只要排序好输出中间那个数就好。

#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int a[1000001];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
printf("%d\n",a[(n+1)/2]);
}
return 0;
}


举报

相关推荐

0 条评论