提交时间:2023-08-23 14:40:47

运行 ID: 99645

#include<bits/stdc++.h> using namespace std; int main(){ int n; int a[10001]; scanf("%d",&n); for(int i = 0;i < n;i++){ scanf("%d",&a[i]); } for(int i = 0;i < n-1;i++){ for(int j = 1;j < n;j++){ if(a[j] > a[j+1]){ int tmp = a[j]; a[j] = a[j+1]; a[j+1] = tmp; } } } int sum = a[0]; int zong = 0; for(int i = 1;i < n;i++){ sum += a[i]; zong += sum; } printf("%d",zong); return 0; }