#include<bits/stdc++.h>
using namespace std;
int f = 0;
int mid(int a[], int n)
{
sort(a, a+n);
int m, t;
if(t%2 == 0)
{
t = n/2;
if(a[t-1] == a[t])
f = 1;
else
f = 2;
m = (a[t-1]+a[t])/2;
}
else
{
t = n/2;
f = 1;
m = a[t];
}
return m;
}
int main()
{
int n, i;
while(cin >> n)
{
int a[n];
map<int, int>mp;
for(i=0;i<n;i++)
{
cin >> a[i];
mp[a[i]]++;
}
f = 0;
int m = mid(a, n);
cout << m << " " << mp[m] << " " << f << "\n";
}
return 0;
}
using namespace std;
int f = 0;
int mid(int a[], int n)
{
sort(a, a+n);
int m, t;
if(t%2 == 0)
{
t = n/2;
if(a[t-1] == a[t])
f = 1;
else
f = 2;
m = (a[t-1]+a[t])/2;
}
else
{
t = n/2;
f = 1;
m = a[t];
}
return m;
}
int main()
{
int n, i;
while(cin >> n)
{
int a[n];
map<int, int>mp;
for(i=0;i<n;i++)
{
cin >> a[i];
mp[a[i]]++;
}
f = 0;
int m = mid(a, n);
cout << m << " " << mp[m] << " " << f << "\n";
}
return 0;
}
Comments
Post a Comment