liuchijun @ 2024-11-27 13:31:07
祭录
#include<cstdio>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#define ll long long
#define db double
//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
int n;
db a[110],ave,sum=0;
db maxn=-1e9,maxn1=-1e9,minn=1e9;
int pos1,pos2;
int main()
{
ios::sync_with_stdio(false);
std::cin.tie(0),std::cout.tie(0);
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lf",&a[i]),sum+=a[i];
for(int i=1;i<=n;i++)
{
if(maxn<a[i])
maxn=a[i],pos1=i;
if(minn>a[i])
minn=a[i],pos2=i;
}
ave=(sum-maxn-minn)/(n-2);
a[pos1]=ave,a[pos2]=ave;
for(int i=1;i<=n;i++)
maxn1=max(maxn1,fabs(a[i]-ave));
printf("%.2lf %.2lf",ave,maxn1);
return 0;
}
by zyxzyx100219 @ 2024-11-27 13:42:05
double a[110] 开小了 @liuchijun
by liuchijun @ 2024-11-27 13:47:07
@zyxzyx100219 不祭录\ 已AC已关,xxn