728x90
반응형
단순 구현
#include <iostream>
#include <unordered_set>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int N;
cin >> N;
vector<int> times;
for (int i = 0; i < N; i++)
{
int t;
cin >> t;
times.push_back(t);
}
sort(times.begin(), times.end());
int total = 0;
int hap = 0;
for (int t : times)
{
hap += t;
total += hap;
}
cout << total;
return 0;
}
728x90
반응형
'Baekjoon > Silver' 카테고리의 다른 글
Baekjoon 1436.영화감독 슘 c++ [Silver V] (0) | 2024.12.28 |
---|---|
Baekjoon 17219.비밀번호 찾기 c++ [Silver IV] (1) | 2024.12.23 |
Baekjoon 1764.듣보잡 c++[Silver IV] (1) | 2024.12.18 |
Baekjoon 11723.집합 c++ [Silver V] (1) | 2024.12.13 |
Baekjoon 1874.스택 수열 c++ [Silver II] (1) | 2024.12.09 |