2 条题解

  • 0
    @ 2026-04-18 12:49:54
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+5;
    int n,a[N];
    int main()
    {
        while(cin>>n)
        {
            int sum{0},maxx{0};
            for(int i=1;i<=n;i++)
            {
                cin>>a[i];
                sum+=a[i];
                if(a[i]>maxx)
                    maxx=a[i];
            }
            if(maxx>sum-maxx)
                cout<<fixed<<setprecision(1)<<(double)(sum-maxx)<<endl;
            else 
                cout<<fixed<<setprecision(1)<<sum/2.0<<endl;
        }
        return 0;
    }
    
  • 0
    #include<bits/stdc++.h>
    using namespace std;
    int n,a[137891],t;
    int main()
    {
        while (cin>>n)
        {
            for (int i=1;i<=n;i++)
            {
                cin>>a[i];
            }
            int xb;
            double sum=0,hmax=0;
            for (int i=1;i<=n;i++)
            {
                if (a[i]>hmax)
                    hmax=a[i],xb=i;
            }
            for (int i=1;i<=n;i++)
            {
                if (i==xb)
                    continue;
                sum+=a[i];
            }
            if (sum>=hmax)
            {
                cout<<fixed<<setprecision(1)<<(sum+hmax)/2*1.0<<endl;
            }
            else
            {
                cout<<fixed<<setprecision(1)<<sum*1.0<<endl;
            }
        }
        return 0;
    }
    
    
  • 1

信息

ID
3067
难度
7
分类
(无)
标签
递交数
109
已通过
19
通过率
17%
上传者