51nod 2133 排队接水

Bryce1010模板

http://www.51nod.com/onlineJudge/questionCode.html#!problemId=2133

#include <bits/stdc++.h>

using namespace std;

int a[1100];


int main()
{
    //cout << "Hello world!" << endl;
    int n;
    cin>>n;
    int sum=0;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        //sum+=(n-i+1)*x;

    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        sum+=(n-i+1)*a[i];
    }

    cout<<sum<<endl;
    return 0;
}
posted @ 2018-07-22 11:43  Bryce1010  阅读(86)  评论(0编辑  收藏  举报