Another Goose Goose Duck Problem
시간 제한1초메모리 제한1024 MB
쿨다운 범위 [l, r]과 b초마다 등장하는 거위, 목표 k마리가 주어질 때, 정수 쿨다운 a를 [l, r]에서 하나 골라 k마리를 처치하는 최소 시간을 구한다.
문제
Teacher Rice likes playing the famous game 'Goose Goose Duck'. In the game, Teacher Rice plays a duck and his goal is to kill the geese. Every time he kills a goose, he should wait seconds for his killing skill to cool down. Since Teacher Rice's role is the Serial Killer, the time Teacher Rice waits depends on which type of goose he kills. Because Teacher Rice is a skilled killer, he can make the waiting time to be an arbitrary integer in .
Teacher Rice meets a goose every seconds. Once Teacher Rice meets a goose, he can choose to kill the goose if his killing skill is ready, otherwise the goose runs away immediately and he can not kill this goose.
Teacher Rice wants to know the minimum time he needs to kill geese.
입력
There are four integers in one line: , , , (, ).
출력
Output one integer denotes the time Teacher Rice needs to kill geese.