题目描述
Problem Description
The math exam at Luogu Primary School consists of several multiple-choice questions. These questions are categorized into three levels: easy, medium, and hard. Each category has its scoring criteria:
- Easy questions: Correct answers earn $5$ points, while incorrect answers earn no points.
- Hard questions: Correct answers earn $20$ points, but incorrect answers result in a deduction of $20$ points.
Luogu Primary School discourages students from focusing on hard questions at the expense of foundational knowledge. Therefore, if the total points earned from easy questions do not exceed the given threshold $M$, correct answers to hard questions will not earn any points, and incorrect answers will still result in a deduction of $20$ points. Additionally, to protect students' feelings, if the total score falls below $0$, it will be counted as $0$ points.
Given the number of easy questions $a$, the number of hard questions $b$, the number of correct easy questions $c$, the number of correct hard questions $d$, and the given point threshold $M$, determine how many points A will ultimately earn.
Input Format
A single line containing five positive integers $a, b, c, d, M$, representing the number of easy questions, the number of hard questions, the number of correct easy questions, the number of correct hard questions, and the given point threshold, respectively.
Output Format
A single line containing an integer representing the final score A will earn.
Sample Input and Output
Input Sample #1
10 5 7 4 30
Output Sample #1
95
Input Sample #2
10 5 7 4 40
Output Sample #2
15
Input Sample #3
10 5 7 1 40
Output Sample #3
0
Notes
[Sample Explanation]
- For Sample $1$, A correctly answered $7$ easy questions, earning $35$ points, which exceeds the given threshold of $30$ points. Therefore, the scores for hard questions are calculated normally. A correctly answered $4$ hard questions, earning $80$ points, but missed one, resulting in a deduction of $20$ points. The total is $35 + 80 - 20 = 95$ points.
- For Sample $2$, A correctly answered $7$ easy questions, earning $35$ points, which does not exceed the threshold of $40$ points. Therefore, only the deductions for incorrect hard questions are calculated, resulting in a total of $35 - 20 = 15$ points.
- For Sample $3$, similar to Sample $2$, only the deductions for incorrect hard questions are calculated. A correctly answered $1$ hard question, resulting in a deduction of $80$ points. Since the total score is below $0$, it is counted as $0$ points.
[Data Range]
For all data, it is guaranteed that: $1 \leq a, b, c, d \leq 100$, $1 \leq c \leq a$, $1 \leq d \leq b$, $1 \leq M \leq 500$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分