[20250727] BOJ / G5 / 사과나무 / 이종환 #556
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/20002
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
첫 번째 줄에는 과수원의 크기 N이 주어진다. (1 ≤ N ≤ 300)
두 번째 줄부터 N + 1번째 줄까지, 해당 나무를 수확했을 때 얻을 수 있는 총이익을 표시한다.
총이익은 -1,000보다 크거나 같고, 1,000보다 작거나 같은 정수이다.
k x k 크기의 정사각형 모양으로만 수확해 가져갈 수 있을 때, 얻을 수 있는 최댓값을 구하라
🔍 풀이 방법
전형적인 누적합 문제이다.
정사각형 모양의 누적합을 구하는 로직을 만든 후, 각각의 위치에서 만들 수 있는 정사각형별 값을 계산하면 된다.
⏳ 회고
크게 어렵진 않지만, 누적합에서 써야할건 다 들어가있어서 연습하기 좋았다.