[20251028] BOJ / G5 / 가장 긴 짝수 연속한 수열(large) #1250
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/22862
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
길이가$N$ 인 수열 $S$ 가 있다.$S$ 는 1 이상인 정수로 이루어져 있다.
수열
수열$S$ 에서 원하는 위치에 있는 수를 골라 최대 $K$ 번 삭제를 할 수 있다.
예를 들어, 수열
$S$ 가 다음과 같이 구성되어 있다고 가정하자.
수열 S : 1 2 3 4 5 6 7 8
수열$S$ 에서 4번째에 있는 4를 지운다고 하면 아래와 같다.
수열 S : 1 2 3 5 6 7 8
수열$S$ 에서 최대 $K$ 번 원소를 삭제한 수열에서 짝수로 이루어져 있는 연속한 부분 수열 중 가장 긴 길이를 구해보자.
🔍 풀이 방법
투포인터를 진행하면 간단하게 진행할 수 있다. 단 홀수인경우 길이가 아닌 지우는 횟수를 늘리는 식으로 진행하면된다.
⏳ 회고