## GlobeX Cup '18 S2 - Test Scores

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

At the start of the semester, your teacher hands you a course outline. The outline states that there will be tests, each of which will be out of marks.

You would like your parents to see a mark that is higher than or equal to on your report card.

As of right now, you have predicted that for each test that will happen, you will score if you do not study at all. From there, you can increase your mark by point for every hours you study.

Find out the minimum total number of hours you need to study for all tests. Note that each test is weighted the same.

#### Input Specification

Line contains integers , , and , separated by a space. is the number of tests throughout the semester. is the number of marks that each test is scored out of. is the minimum mark that you will accept on your report card.

Lines to : The line contains the integers and , separated by a space, where . is the predicted score on test if you do not study at all. is the number of hours you need to study to increase your score by on that test.

#### Output Specification

Output the minimum number of hours you need to study to get a mark of at least on your report card.

#### Sample Input

5 7 6
5 3
6 4
7 1
1 5
3 3

#### Sample Output

27

#### Sample Explanation

You can increase your score on the first test up to 7 by studying for 6 hours. You can then increase your score on the second test by 1 point with 4 hours of studying. You can increase your score on the fourth test by 1 point with 5 hours of studying. Finally, increase your score on the last test up to 7 by studying for 12 hours.

Note that you cannot increase your score on any test to have a value of greater than 7 as the tests are out of 7 marks.