Baekjoon

[#11399] ATM

강람이 2020. 3. 13. 14:08
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
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    vector<int> time(n);
    
    for (int i = 0; i < n; i++) {
        cin >> time[i];
    }
 
    sort(time.begin(), time.end());  //인출하는데 필요한 시간이 작은 순으로 정렬
 
    int result = 0;
    int temp = 0;
    
    for (int i = 0; i < n; i++) {
        temp = temp + time[i]; //i번째 사람마다 필요한 시간은 i-1번째 사람이 필요한 시간 + 자기가 필요한 시간
        result = result + temp;
    }
    
    cout << result;
    
    return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

 

가장 짧은 시간이 필요한 사람부터