Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/26268
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
수직선 상에 서로 다른 N개의 지점에 은행이 존재한다.
i번째 은행은 좌표 x[i]에 존재하며, 시간 t[i]에만 문이 열리고 털면 c[i]원을 얻는다.
시우는 직선상에서 임의의 정수 좌표에서 시작해 움직이고, 움직이는 동안 좌표는 감소하지 않아야 한다.
1만큼 이동할 때 시간이 1만큼 걸린다. 얻을 수 있는 최대 금액을 구해보자.
🔍 풀이 방법
i번째 은행 (x[i], t[i], c[i])를 턴다고 가정하자.
시우는 도중에 멈춰있을 수 있으니까, x[j] < x[i]이면서 t[j] - x[j] <= t[i] - x[i]인 j번째 은행을 턴 뒤에 i번째 은행을 털 수 있다.
dp식을 설계해보자.
dp[i] = max(dp[j]) + c[i]가 성립한다.
은행들을 t[i] - x[i] 기준 오름차순으로 정렬해놓고, 최댓값을 관리하는 세그먼트 트리로 dp식을 이용해 정답을 구한다.
⏳ 회고
ezpz