#B3886. Score Calculation in LoGu Primary School Math Exam

    ID: 11543 Type: Default 1000ms 256MiB

Score Calculation in LoGu Primary School Math Exam

Score Calculation in LoGu Primary School Math Exam

LoGu Primary School's math exam consists of several multiple choice questions categorized into three difficulty levels: Simple, Medium, and Difficult. In this problem, we only consider Simple and Difficult questions with the following scoring rules:

  • Simple Questions: Each correct answer earns \(5\) points, and no points are awarded for an incorrect answer.
  • Difficult Questions: Each correct answer normally earns \(20\) points while an incorrect answer penalizes \(20\) points.

However, the school strives to ensure that students do not neglect the basics. Therefore:

  • If the total score from simple questions \( (\text{number of correct simple answers} \times 5) \) is \( \le M \), then even if a difficult question is answered correctly, it gives \(0\) points. (Wrong answers in difficult questions still result in a penalty of \(20\) points.)

Finally, if the cumulative score of all questions is negative, the final score is set to \(0\).

You are given the following five integers:

  1. \(a\): The total number of simple questions in the exam.
  2. \(b\): The total number of difficult questions in the exam.
  3. \(c\): The number of simple questions answered correctly by the student.
  4. \(d\): The number of difficult questions answered correctly by the student.
  5. \(M\): The score limit for simple questions.

Compute the student's final score according to the rules above.

inputFormat

The input consists of a single line containing five space-separated integers: \(a\), \(b\), \(c\), \(d\), and \(M\).

outputFormat

Output a single integer representing the student's final score.

sample

10 5 4 3 20
0