====== 제자리 멀리뛰기 ====== ===== 풀이 ===== * [[ps:problems:programmers:43236]]과 동일한 문제. 풀이는 그쪽 참고. ===== 코드 ===== """Solution code for "BOJ 6209. 제자리 멀리뛰기". - Problem link: https://www.acmicpc.net/problem/6209 - Solution link: http://www.teferi.net/ps/problems/boj/6209 Tags: [Parametric Search] """ import sys from teflib import binsearch def main(): def is_valid(min_dist): prev_rock = 0 removed_rock_count = 0 for rock in rocks: if rock - prev_rock < min_dist: removed_rock_count += 1 else: prev_rock = rock if d - prev_rock < min_dist: removed_rock_count += 1 return removed_rock_count <= m d, n, m = [int(x) for x in sys.stdin.readline().split()] rocks = [int(sys.stdin.readline()) for _ in range(n)] rocks.sort() print(binsearch.maximum_valid_integer(0, d // (n - m + 1) + 1, is_valid)) if __name__ == '__main__': main() * Dependency: [[:ps:teflib:binsearch#maximum_valid_integer|teflib.binsearch.maximum_valid_integer]] {{tag>BOJ ps:problems:boj:골드_2}}