[20250921] BOJ / G4 / 수들의 합 4 / 이강현 #941
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/2015
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
i부터 j까지의 합이 K가 되는 경우의 수 출력.
🔍 풀이 방법
누적합, 맵
입력받을때 누적합 구해놓기
i부터 j까지의 합이 K라는 건
A[j] - A[i-1] = K임.
배열의 앞에서부터 A[j]-K를 집합에서 찾고 있으면 카운트하는 방식.
즉, j가 i의 역할도 함께 하는 것.
⏳ 회고
누적합까지 바로 생각하고 투포인터를 써야하나 했는데 값들이 정수라서 고민했다.
정수일때, 누적합을 맵을 통해 구해낼 수 있다는 것을 알게 되었다.