7 solutions
-
0
排序所有人打水时间,让短的先打,就节约时间,可以自己写例子试
上代码
#include<bits/stdc++.h> using namespace std; int main() { int n,a[100005]={0}; long long sum=0,s=0; scanf("%d",&n); for(int i=0;i<n;i++)scanf("%d",&a[i]); sort(a,a+n); for(int i=0;i<n-1;i++) { s+=a[i]; sum+=s; } printf("%lld",sum); return 0; }
Information
- ID
- 76
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 256
- Accepted
- 81
- Uploaded By