[20251013] BOJ / P4 / Pilots / 권혁준 #1102
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/8201
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
길이 N인 수열 A에서 max(A[i], ..., A[j]) - min(A[i], ..., A[j]) <= T를 만족하는 j-i+1의 최댓값을 구해보자.
🔍 풀이 방법
문제에 써있는 조건을 그대로 써서
투 포인터를 돌리면 된다.구간 max와 min을 구할 때는
세그먼트 트리로 구했다.⏳ 회고
처음엔 multiset으로 max, min을 구했는데 메모리 초과가 남.
세그먼트 트리로 겨우 뚫긴 했는데 덱을 쓰면 널널하게 통과가 됨.
왜 덱을 떠올리지 못했지?