Submission
Status:
[PP][P][P][P][P]
Subtask/Task Score:
{20/20}{20/20}{20/20}{20/20}{20/20}
Score: 100
User: ssens3
Problemset: ติดตั้งหลอดไฟ
Language: cpp
Time: 0.004 second
Submitted On: 2026-09-30 15:15:11
#include <iostream>
using namespace std;
int main(){
int n, t, s = 0; cin >> n; int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++){
for (int j = 0; j < n-i-1; j++){
if (a[j] > a[j+1]){
t = a[j+1];
a[j+1] = a[j];
a[j] = t;
}
}
}
for (int i = 0; i < n; i++){
for (int j = i; j >= 0; j--){
s += 2 * a[j];
}
}
cout << s;
}