C. Petya and Exam
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.
The exam consists of nn problems that can be solved in TT minutes. Thus, the exam begins at time 00 and ends at time TT. Petya can leave the exam at any integer time from 00 to TT, inclusive.
All problems are divided into two types:
- easy problems — Petya takes exactly aa minutes to solve any easy problem;
- hard problems — Petya takes exactly bb minutes (b>ab>a) to solve any hard problem.
Thus, if Petya starts solving an easy problem at time xx, then it will be solved at time x+ax+a. Similarly, if at a time xx Petya starts to solve a hard problem, then it will be solved at tim