This repository was archived by the owner on Mar 18, 2024. It is now read-only.
[2023-07-09] jisu #81 #83
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.
PR Summary
1시간 정도 소요
[제한조건]
5 <= len(sequence) <= 1,000,000
1 <= sequence <= 1,000
5 <= k <= 1,000,000,000
[idea]
0, 1, 2, ... i 번째 원소부터 누적합을 구한 후, 누적합이 k인 경우 찾기
이 때 기본 오름차순으로 정렬되어 있으므로 누적합은 항상 증가하는 방향이다.
또한 오름차순인 것에 힌트, 누적합이 k인 경우를 찾을 때 이진 탐색을 활용할 수 있다.
[누적합 활용]

sequence의 각 원소를 해당 원소까지의 누적 합으로 업데이트 한 후, i번째 원소 전까지의 누적합을 빼어
i번째부터의 누적합을 활용할 수 있다.
[이진 탐색]
i번째 인덱스 부터의 인덱스를 활용할 수 있다면, 오름차순으로 정렬되어있음을 활용해 k를 탐색하는 과정에서 이진 탐색(파라메트릭 서치)을 적용할 수 있다.
ISSUE NUMBER