Submission

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

Score: 100

User: ShynyC

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

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-31 21:01:52

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    //sort by acsending order
    int n,temp,total = 0,sum = 0;
    cin >> n;
    vector<int> lengths;
    for(int i = 0; i < n; i++){
        cin >> temp;
        lengths.push_back(temp);
    }
    sort(lengths.begin(),lengths.end());
    for(int i = 0; i < n; i++){
        total = total + lengths[i];
        sum = sum + total*2;
    }
    cout << sum;
}