You need to go up n floors (from floor 0 to floor n). You may:
k
floors, where
0 ≤ k ≤ n
.
e1
energy.
t1
time.
k
floors, your energy is
E = k * e1
.
n - k floors by stairs
.
E
, the time spent on that floor is:
- After climbing that floor, your energy decreases by `e2`:
`E := E - e2`
E ≥ e2
(so that after subtracting
e2
you still have
E ≥ 0
).
Your task is to choose k to minimize the total travel time.
Five integers:
n
: number of floors to go up
e1
: energy gained per elevator floor
t1
: time per elevator floor
e2
: energy spent per stair floor
c
: constant used in stair time formula
Return the minimum possible total time to reach floor n.
n
for any
k
(i.e., you can’t complete the stair portion without energy going negative), return
-1
.
e2
for that floor.