-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1139.cpp
More file actions
46 lines (35 loc) ยท 706 Bytes
/
1139.cpp
File metadata and controls
46 lines (35 loc) ยท 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// 1139.cpp
// algo
//
// Created by ๋ฐํจ์ on 2021/04/27.
//
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
cin.tie(0);
cout.tie(0);
std::ios::sync_with_stdio();
int n;
cin>>n;
vector<int>v(n);
int res=0;
//๊ฐ ์
๋ ฅ
for(int i=0;i<n;i++){
cin>>v[i];
}
//์ค๋ฆ์ฐจ ์ ๋ ฌ
sort(v.begin(), v.end());
for(int i=0;i<n;i++){
//๋ด๊ฐ ์ธ์ถํ ๋ ๊ฑธ๋ฆฌ๋ ์๊ฐ ๋ํ๊ธฐ
res+=v[i];
for(int j=0;j<i;j++){
//์ ์ฌ๋ ์ธ์ถ ๊ฐ ๋ํ๊ธฐ
res+=v[j];
}
}
cout<<res<<"\n";
return 0;
}