백준 11399 c++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int input(int lower, int upper)
{
//cout << "input()" << endl;
int A;
while (1)
{
cin >> A;
if (A >= lower && A <= upper)
{
break;
}
else
{
;
}
}
return A;
}
void input_vector(vector <int>& A, int N)
{
//cout << "input_vector()\n";
int i;
for (i = 0; i < N; i++)
{
A.push_back(input(1, 1000));
}
return;
}
void sort_vec(vector <int>& A)
{
sort(A.begin(), A.end());
return;
}
int find_result(vector <int> A)
{
//cout << "find_result\n";
int N = A.size();
int sum = 0, total = 0;
int i;
for (i = 0; i < N; i++)
{
sum = sum + A[i];
total = total + sum;
}
return total;
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N, i;
vector <int> P;
N = input(1, 1000);
input_vector(P, N);
sort_vec(P);//필요시간순으로 정렬
cout << find_result(P) << "\n";
return 0;
}