7 solutions
-
0
题解
思路还是简单,把打水时间从小到大进行排序即可,注意一点,在打水的人本身不算等待的时间,直接上代码:
代码
#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<iomanip> using namespace std; int x[100000000],y[17]; char a[11],b[18]; struct Main{ char a[20]; int cheng; }pp[300]; int cmp(Main x,Main y){ return x.cheng>y.cheng; } int main() { long long n,m,sum=0; cin>>n; m=n-1; for(long long i=1;i<=n;i++){ cin>>x[i]; } sort(x+1,x+1+n); for(long long i=1;i<=n;i++){ sum+=x[i]*m; m--; } cout<<sum<<endl; return 0; }
Information
- ID
- 76
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 251
- Accepted
- 78
- Uploaded By