Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- ๋ฐฑํธ๋ํน
- Spring
- java
- GCP
- ๋งต
- web
- ์ต๋จ ๊ฒฝ๋ก
- ์์ ์ ๋ ฌ
- ๊ทธ๋ฆฌ๋
- error
- ๋ถํ ์ ๋ณต
- DP
- ๋์ ํฉ
- dfs
- BFS
- dynamic debugging
- ์ฌ๊ท
- c++
- CVE
- ์ด๋ถ ํ์
- JPA
- Reversing
- ์ฐ์ ์์ ํ
- ์๋ฎฌ๋ ์ด์
- thymeleaf
- ๋ฐ์ดํฌ์คํธ๋ผ
- ์คํ
- OS
- ๊ตฌํ
- ๋ฌธ์์ด
Archives
- Today
- Total
hades
[Baekjoon] 11399๋ฒ: ATM ๋ณธ๋ฌธ
๐ฅ ๋ฌธ์
https://www.acmicpc.net/problem/11399
๐ ์ค๊ณ
์ธ์ถํ๋๋ฐ ์๊ฐ์ ๋ง์ด ์ฐ๋ ์ฌ๋์ด ์์ ์ค๋ฉด, ๋ค์ ์ฌ๋๋ค์ด ๊ธฐ๋ค๋ ค์ผ ํ๋ ์๊ฐ์ด ๊ทธ๋งํผ ๋์ด๋๋ฏ๋ก, ์ธ์ถ ์๊ฐ์ ๊ธฐ์ค์ผ๋ก ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌํ๋ค. ์ด๋ค ์ฌ๋์ด ์ธ์ถํ๋๋ฐ๊น์ง ๊ฑธ๋ฆฌ๋ ์๊ฐ์ ์ ์ฌ๋๋ค์ด ์ธ์ถํ๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ + ๋ณธ์ธ์ด ์ธ์ถํ๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ์ด๋ค.
๐ ํ์ด
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
vector<int> p;
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
p = vector<int>(n);
for (int i = 0; i < n; i++) {
cin >> p[i];
}
sort(p.begin(), p.end());
int temp_sum = 0;
int result = 0;
for (int i = 0; i < n; i++) {
temp_sum += p[i];
result += temp_sum;
}
cout << result << "\n";
return 0;
}
'๐ PS > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Baekjoon] 11659๋ฒ: ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ (0) | 2024.07.25 |
---|---|
[Baekjoon] 11403๋ฒ: ๊ฒฝ๋ก ์ฐพ๊ธฐ (0) | 2024.07.25 |
[Baekjoon] 11286๋ฒ: ์ ๋๊ฐ ํ (1) | 2024.07.23 |
[Baekjoon] 10026๋ฒ: ์ ๋ก์์ฝ (2) | 2024.07.22 |
[Baekjoon] 9095๋ฒ: 1, 2, 3 ๋ํ๊ธฐ (1) | 2024.07.20 |