LCC '22 Contest 4 J3 - Aaron Adjures

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type

Semester 1 is finally over, and Aaron has just gotten his functions exam back! Unfortunately, he received a score of S, and it's not a 100. Thus, Aaron decides to go to Ms. Spiliopoulos to adjure her to give him more marks.

Max warns Aaron that while he can go have his exam reviewed, the longer he spends, the more likely Ms. Spiliopoulos is to catch the questions Aaron got wrong but were still marked correctly (there were many). In fact, given that Aaron spends x minutes begging for marks, and \{x \in \mathbb{R} | x > 0\}, his mark can be modelled by the equation y = S-ax^2+bx-c, \{0 \le y \le 100\}.

Unfortunately for Aaron, not only had he not solved the questions on the exam, but he can't seem to solve this equation either. Can you help Aaron determine what his maximal score is?


0 \le S \le 99

1 \le a,b \le 10^9

1 \le c \le 10^{18}

Input Specification

The first and only line of input contain 4 integers: S, a, b, and c.

Output Specification

Output Aaron's maximal score, to the nearest integer. Note that it may be optimal for Aaron to not go adjure for marks at all.

Sample Input

60 3 21 3

Sample Output


Sample Explanation

If Aaron spends 3.5 minutes asking for marks, he will receive a score of 93.75, which rounds to 94. It can be proven this is the highest score possible.


There are no comments at the moment.