60分求助

P5738 【深基7.例4】歌唱比赛

@[zch120526](/user/1390387) 没清空a数组 #include <bits/stdc++.h> using namespace std; int main(){ long long n,m,b; cin>>n>>m; vector<double>h; for(int i=1;i<=n;i++){ vector<int>a; for(int j=1;j<=m;j++){ cin>>b; a.push_back(b); } sort(a.begin(),a.end()); double sum=0; for(int i=1;i<m-1;i++){ sum=sum+a[i]; } h.push_back(sum/(m-2)); } sort(h.begin(),h.end()); cout<<fixed<<setprecision(2)<<h[n-1]; } ```
by zyc230808chenwei @ 2024-09-08 20:17:09


``` #include <bits/stdc++.h> using namespace std; int main(){ long long n,m,b; cin>>n>>m; vector<double>h; for(int i=1;i<=n;i++){ vector<int>a; for(int j=1;j<=m;j++){ cin>>b; a.push_back(b); } sort(a.begin(),a.end()); double sum=0; for(int i=1;i<m-1;i++){ sum=sum+a[i]; } h.push_back(sum/(m-2)); } sort(h.begin(),h.end()); cout<<fixed<<setprecision(2)<<h[n-1]; } ``` @[zch120526](/user/1390387)
by zyc230808chenwei @ 2024-09-08 20:18:50


|