11399번: ATM

myeongrangcoding·2023년 12월 15일
0

백준

목록 보기
24/47

https://www.acmicpc.net/problem/11399

구현 6분

풀이

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "rt", stdin);

	int N{};
	cin >> N;

	priority_queue<int> pQ;

	for (int i = 0; i < N; ++i)
	{
		int Seconds{};
		cin >> Seconds;
		pQ.push(-Seconds);
	}

	int Sum{}, Answer{};

	while (!pQ.empty())
	{
		int Out = -pQ.top();
		pQ.pop();

		Sum += Out;
		Answer += Sum;
	}

	cout << Answer;

	return 0;
}
profile
명랑코딩!

0개의 댓글