11399번 ATM(백준)


#include <iostream>
#include <algorithm>

using namespace std;

const int MAX = 1000;
int Arr[MAX];



bool cmp(int a, int b)
{
	return a < b;
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> Arr[i];
	}
	
	int iResult = 0;
	sort(Arr, Arr+N, cmp);

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			iResult += Arr[j];
		}
	}
	cout << iResult<<endl;

	return 0;
}

좋은 웹페이지 즐겨찾기