[20251113] BOJ / G5 / 빗물 / 설진영 #1400
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/14719
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
2차원 세계에 블록이 쌓여있고, 비가 올 때 블록 사이에 고이는 빗물의 총량 구하기
각 위치에서 고일 수 있는 물의 양은 해당 위치의 왼쪽 최대 높이와 오른쪽 최대 높이 중 작은 값에서 현재 블록 높이를 뺀 값
🔍 풀이 방법
왼쪽에서 현재 위치까지의 최대 블록 높이
오른쪽에서 현재 위치까지의 최대 블록 높이
두 값 중 최솟값에 현재 블록 높이를 빼면 고이는 물의 양
가장자리는 물이 고일 수 없으므로 제외
⏳ 회고
그냥 구현