中位數問題。
//ignore header files
int main(int argc, char const* argv[])
{
int n;
int input[1000000];
while(scanf("%d",&n) != EOF){
map<int,int> t;
for(int i = 0;i<n;i++){
int m;
scanf("%d",&m);
input[i] = m;
if(t[m] == false){
t[m] = 1;
}else{
t[m]++;
}
}
sort(input,input+n);
int c1,c2,c3;
if(n%2 == 0){
int a = n/2;
c1 = input[a-1];
if(input[a-1] != input[a])
c2 = t[input[a-1]]+t[input[a]];
else
c2 = t[input[a-1]];
c3 = input[a]-input[a-1]+1;
}
else{
int a = n/2;
c1 = input[a];
c2 = t[input[a]];
c3 = 1;
}
printf("%d %d %d\n",c1,c2,c3);
}
return 0;
}