CF887D Ratings and Reality Shows
Description
There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by $ a $ and after each fashion show decreases by $ b $ (designers do too many experiments nowadays). Moreover, sometimes top-models participates in talk shows. After participating in talk show model becomes more popular and increasing of her rating after photo shoots become $ c $ and decreasing of her rating after fashion show becomes $ d $ .
Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will never become negative. Help her to find a suitable moment for participating in the talk show.
Let's assume that model's career begins in moment 0. At that moment Izabella's rating was equal to $ start $ . If talk show happens in moment $ t $ if will affect all events in model's life in interval of time $ [t..t+len) $ (including $ t $ and not including $ t+len $ ), where $ len $ is duration of influence.
Izabella wants to participate in a talk show, but she wants to do it in such a way that her rating will not become become negative before talk show or during period of influence of talk show. Help her to find a suitable moment for participating in the talk show.
Input Format
In first line there are 7 positive integers $ n $ , $ a $ , $ b $ , $ c $ , $ d $ , $ start $ , $ len $ ( $ 1
Output Format
Print one non-negative integer $ t $ — the moment of time in which talk show should happen to make Izabella's rating non-negative before talk show and during period of influence of talk show. If there are multiple answers print smallest of them. If there are no such moments, print $ -1 $ .