Coding Test - cpp/Greedy
[백준 11399: ATM] - C++
에드윈H
2021. 2. 8. 20:10
#include<iostream>
#include<algorithm>
using namespace std;
int arr[1001];
int time[1001];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
sort(arr,arr+n);
time[0] = arr[0];
int result = time[0];
for (int i = 1; i <n; i++)
{
time[i]=arr[i]+ time[i-1];
result += time[i];
}
cout << result << endl;
return 0;
}