lfynbklsKNYYDS888666 @ 2024-12-08 11:41:14
#include<bits/stdc++.h>
using namespace std;
int n,tmax,tmin,sum;
double a[305],maxx=INT_MIN,minn=INT_MAX,ave,maax=INT_MIN,miin=INT_MAX;
bool f,f_;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]>maxx)
{
maxx=a[i];
tmax=i;
}
if(a[i]<minn)
{
minn=a[i];
tmin=i;
}
sum+=a[i];
}
for(int i=1;i<=n;i++)
{
if(a[i]==maxx&&!f)
{
sum-=a[i];
f=true;
continue;
}
if(a[i]==minn&&!f_)
{
sum-=a[i];
f_=true;
continue;
}
if(a[i]>maax)
{
maax=a[i];
}
if(a[i]<miin)
{
miin=a[i];
}
}
ave=sum/(n-2)*1.0;
printf("%.2lf ",ave*1.0);
printf("%.2lf",max(max(ave,maax)-min(ave,maax),max(ave,miin)-min(ave,miin))*1.0);
}
by lfynbklsKNYYDS888666 @ 2024-12-08 11:41:36
https://www.luogu.com.cn/record/193483893