#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int>v;
int ans = 0;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N; cin >> N;
int cnt = N;
for (int i = 0; i < N; i++) {
int number; cin >> number;
v.push_back(number);
}
sort(v.begin(), v.end());
for (int i = 0; i < N; i++ ) {
ans+=v[i] * cnt; // ex) N=5์ผ๋ 1x5, 2x4, 3x3, 4x2, 5x1
cnt--;
}
cout << ans;
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 11441๋ฒ - ํฉ ๊ตฌํ๊ธฐ (0) | 2021.10.27 |
---|---|
[๋ฐฑ์ค,c++] 11404๋ฒ - ํ๋ก์ด๋ (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 11403๋ฒ - ๊ฒฝ๋ก ์ฐพ๊ธฐ (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 1138๋ฒ - ํ ์ค๋ก ์๊ธฐ (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 11365๋ฒ - !๋ฐ๋น ๊ธ์ผ (0) | 2021.10.27 |
[๋ฐฑ์ค,c++] 11328๋ฒ - strfry (0) | 2021.10.27 |
๋๊ธ