From 4b750ab033ecf0e8ff375cc36eaa2f52d14e45eb Mon Sep 17 00:00:00 2001 From: "YeJun, Jung" Date: Fri, 23 Jan 2026 08:52:15 +0900 Subject: [PATCH 1/2] feat: Add a solution of Programmers p43105 --- problems/programmers/others/p43105/main.cpp | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 problems/programmers/others/p43105/main.cpp diff --git a/problems/programmers/others/p43105/main.cpp b/problems/programmers/others/p43105/main.cpp new file mode 100644 index 0000000..9b947c8 --- /dev/null +++ b/problems/programmers/others/p43105/main.cpp @@ -0,0 +1,63 @@ +/* + * (43105) 정수 삼각형 + */ + +#include + +#include +#include + +using namespace std; + +int solution(vector> triangles) { + int H = triangles.size(); + + // 밑에서 부터 위로 올라가면서 가장 큰 값만 남김 + for (int y = H - 1; y > 0; --y) { + for (int x = 0; x < y; ++x) { + if (triangles[y][x] < triangles[y][x + 1]) { + triangles[y-1][x] += triangles[y][x + 1]; + } else { + triangles[y-1][x] += triangles[y][x]; + } + } + } + + return triangles[0][0]; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + /* + * 테스트 케이스가 입력됨. + * + * 각 테스트에 대해서 첫번째 줄에 높이가 입력되고 다음 줄부터 높이 개수까지 + * 삼각형 정보가 띄어쓰기 기준으로 입력됨 + */ + + int test_count; + cin >> test_count; + + for (int test_case = 1; test_case <= test_count; ++test_case) { + int height; + cin >> height; + + vector> triangles(height); + + for (int h = 0; h < height; ++h) { + triangles[h].resize(h + 1); + + for (int i = 0; i < h + 1; ++i) { + cin >> triangles[h][i]; + } + } + + auto answer = solution(triangles); + cout << "#" << test_case << " " << answer << "\n"; + } + + return 0; +} From 0fc188d339a33de8947af4d21ad19935786c750d Mon Sep 17 00:00:00 2001 From: "YeJun, Jung" Date: Fri, 23 Jan 2026 12:35:32 +0900 Subject: [PATCH 2/2] fix: add problem url --- problems/programmers/others/p43105/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/problems/programmers/others/p43105/main.cpp b/problems/programmers/others/p43105/main.cpp index 9b947c8..d0ee02d 100644 --- a/problems/programmers/others/p43105/main.cpp +++ b/problems/programmers/others/p43105/main.cpp @@ -1,5 +1,6 @@ /* * (43105) 정수 삼각형 + * https://school.programmers.co.kr/learn/courses/30/lessons/43105 */ #include