卡80求调(真的求求了掉蓝名看不了数据)

B2095 白细胞计数

CZH_xixi @ 2024-10-16 17:48:01

#include<bits/stdc++.h>
using namespace std;
double n,a[301],ma=0,mi=100,sum=0,p,q,ma2,mi2;
int main(){
    scanf("%lf",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lf",&a[i]);
        if(ma<=a[i])
        {
            ma2=ma;
        }
        ma=max(ma,a[i]);
        if(mi>=a[i])
        {
            mi2=mi;
        }
        mi=min(mi,a[i]);
        sum+=a[i];
    }

    sum-=ma+mi;
    p=sum/(n-2);
    q=max(abs(ma2-p),abs(p-mi2));
    printf("%.2lf %.2lf",p,q);
}

神犇犇~


by KDL_ANIPLEX @ 2024-10-16 19:27:16

#include<cstdio>
using namespace std;
int n;
double a[305],l=1e9,r,s;
int lu,ru;
double ma(double x,double y)
{
    if (x>y) return x-y;
    return y-x;
}
int main(){
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
    {
    scanf ("%lf",&a[i]);
    if (l>a[i]) l=a[i],lu=i;
    if (r<a[i]) r=a[i],ru=i;
    s+=a[i];
    }
    s=(s-l-r)/(n-2),r=0;
    for (int i=1;i<=n;i++)
    {
        if ((i!=lu)&&(i!=ru))
        l=ma(s,a[i]);
        if (r<l) r=l;
    }
    printf ("%.2lf %.2lf\n",s,r);
    return 0;
}

by CZH_xixi @ 2024-10-17 17:52:27

@KDL_ANIPLEX 这么轩!~,轩轩(谢谢)


by CZH_xixi @ 2024-10-17 17:53:02

@2023_1202 但是不想要ac代码


|