提交时间:2024-08-19 23:13:13
运行 ID: 168156
#include<iostream> #include<algorithm> using namespace std; bool cmp(int a,int b){ return a<b; } int main(){ int a,b[10005]; cin>>a; for(int i=1;i<=a;i=i+1){ cin>>b[i]; } sort(b+1,b+a+1,cmp); int c=b[1],d=b[1]; for(int i=2;i<=a;i=i+1){ c=c+b[i]+d; d=b[i]; } cout<<c; return 0; }