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/16678
🧭 풀이 시간
16분
👀 체감 난이도
✏️ 문제 설명
길이$N$ 인 수열 $A$ 가 주어집니다. $(1 \le A_i \le 100.000)$
버튼을 누르면 다음 과정이 수행됩니다.
버튼을 누르기 전에 원하는 만큼 조작을 할 수 있습니다.$1$ 감소시키는 걸 의미합니다.$A$ 의 모든 원소를 $0$ 으로 만들려고 할 때, 필요한 조작의 최소 횟수를 구해야 합니다.
조작이란, 원소 하나를
버튼을 한 번만 눌러서
🔍 풀이 방법
정렬시키고 작은 수부터 하나씩$1$ 부터 배정하면 됩니다.
만약, 배정하려는 수와 현재 수가 같다면 인접한 같은 수들을 모두 하나로 취급해야 합니다.
⏳ 회고
같은 수들에 대한 처리를 생각하는데 너무 오래 걸렸습니다. 예제가 너무 불친절합니다.