CCF中间数
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
int i,j,count1 = 0,count2 = 0;
for(i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
for(i=0;i<n;i++){
if(a[i]>a[n/2]) count1++;
else if(a[i]<a[n/2])count2++;
}
if(count1 == count2) printf("%d",a[n/2]);
else printf("-1");
return 0;
}
posted on 2017-03-10 19:18 whitehouse 阅读(206) 评论(0) 编辑 收藏 举报