CF864C.Bus

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A bus moves along the coordinate line OxOx from the point x=0x=0 to the point x=ax=a . After starting from the point x=0x=0 , it reaches the point x=ax=a , immediately turns back and then moves to the point x=0x=0 . After returning to the point x=0x=0 it immediately goes back to the point x=ax=a and so on. Thus, the bus moves from x=0x=0 to x=ax=a and back. Moving from the point x=0x=0 to x=ax=a or from the point x=ax=a to x=0x=0 is called a bus journey. In total, the bus must make kk journeys.

The petrol tank of the bus can hold bb liters of gasoline. To pass a single unit of distance the bus needs to spend exactly one liter of gasoline. The bus starts its first journey with a full petrol tank.

There is a gas station in point x=fx=f . This point is between points x=0x=0 and x=ax=a . There are no other gas stations on the bus route. While passing by a gas station in either direction the bus can stop and completely refuel its tank. Thus, after stopping to refuel the tank will contain bb liters of gasoline.

What is the minimum number of times the bus needs to refuel at the point x=fx=f to make kk journeys? The first journey starts in the point x=0x=0 .

输入格式

The first line contains four integers aa , bb , ff , kk ( 0<f<a<=1060<f<a<=10^{6} , 1<=b<=1091<=b<=10^{9} , 1<=k<=1041<=k<=10^{4} ) — the endpoint of the first bus journey, the capacity of the fuel tank of the bus, the point where the gas station is located, and the required number of journeys.

输出格式

Print the minimum number of times the bus needs to refuel to make kk journeys. If it is impossible for the bus to make kk journeys, print -1.

输入输出样例

  • 输入#1

    6 9 2 4
    

    输出#1

    4
    
  • 输入#2

    6 10 2 4
    

    输出#2

    2
    
  • 输入#3

    6 5 4 3
    

    输出#3

    -1
    

说明/提示

In the first example the bus needs to refuel during each journey.

In the second example the bus can pass 1010 units of distance without refueling. So the bus makes the whole first journey, passes 44 units of the distance of the second journey and arrives at the point with the gas station. Then it can refuel its tank, finish the second journey and pass 22 units of distance from the third journey. In this case, it will again arrive at the point with the gas station. Further, he can refill the tank up to 1010 liters to finish the third journey and ride all the way of the fourth journey. At the end of the journey the tank will be empty.

In the third example the bus can not make all 33 journeys because if it refuels during the second journey, the tanks will contain only 55 liters of gasoline, but the bus needs to pass 88 units of distance until next refueling.

首页