题目链接:http://115.28.138.223/view.page?gpid=T52
#include <stdio.h> int main(){ int i,n,a,flag = -1,sum = 0; int count[1001] = {0}; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&a); count[a] ++; } for(i=1;i<=1000;i++){ if(n-count[i]-sum == sum){ //大于中间数的整数数量和小于它的整数数量相同 flag = 1; break; } sum += count[i]; } printf("%d ",(flag == 1)?i:-1); return 0; }