Submission

Status:
[PP][P][P][P][P]

Score: 100

User: Whally

Problemset: ติดตั้งหลอดไฟ

Language: cpp

Time: 0.003 second

Submitted On: 2025-04-13 13:40:44

#include <bits/stdc++.h>
using namespace std;
int t[1010];
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;
    for (int i = 0 ; i < n; i++){
        cin >> t[i];
    }
    sort(t, t+n);
    for (int i = 0; i < n; i++){
        if (i) t[i] += t[i-1];
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += 2*t[i];
    }
    cout << ans;

    return 0;
}