求助!!!!!82#3#10WA
查看原帖
求助!!!!!82#3#10WA
494584
大明yyds楼主2021/7/20 10:16
#include<bits/stdc++.h>
using namespace std;
long long a[1000001],b[1000001],c[1000001],poi=1,n;
double m=0.0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		for(int o=1;o<=100001;o++){
			if(o==a[i])
			b[o]++;
		}
	}

	for(int i=1;i<=100001;i++){
		for(int o=1;o<=n;o++){
			if(b[i]!=0){
				if(a[o]==i){
					cout<<o<<" ";
				}
			}
		}
	}
	for(int i=1;i<=100001;i++){
		while(b[i]!=0){
			c[poi]=i;
			poi++;
			b[i]--;
		}
	}
	for(int i=1;i<=n;i++){
		m=m+c[i]*(n-i);
	}
	cout<<endl;
	cout<<fixed<<setprecision(2)<<m/n;
	return 0;
}
2021/7/20 10:16
加载中...