You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
문제
https://www.acmicpc.net/problem/20444
난이도 : 골드 5
아이디어
0.1초라는 적은 시간에 넓은 탐색 범위 안에서 최적의 조건을 찾아야 하므로 이분탐색으로 먼저 접근해보았다.
n번의 가위질을 했을 때 k개의 색종이 조각을 만들 수 있는 지 판단해야 한다.

하나씩 해보니 아래와 같은 규칙을 발견했다.
그렇다면 가로로 자르는 횟수를 매개변수로 설정한 후 이분탐색을 통해 K값을 찾으면 가능한 것이므로 찾으면 YES를, 못찾으면 NO를 반환해주면 될 것이다.
이분탐색의 범위는 가로로 자르는 횟수의 최소 값이 0이고, 최대 값이 N/2 이하이므로 0~N/2가 된다.

시간복잡도
생각보다 빨리 풀렸던 문제. 언제 한번 비슷한 유형의 문제를 풀어봤던 기억이 있다 😎
구현
Beta Was this translation helpful? Give feedback.
All reactions