Problem3146--数学选择题

3146: 数学选择题

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description

旭景小学的数学考试由若干道选择题组成。选择题分为三档:简单题、中等题和困难题。每类题目都有评判标准:

  • 简单题:回答正确得 lns="http://www.w3.org/1998/Math/MathML">5 分,回答错误则不得分;
  • 困难题:回答正确得 lns="http://www.w3.org/1998/Math/MathML">20 分,回答错误倒扣 lns="http://www.w3.org/1998/Math/MathML">20 分;

旭景小学不鼓励学生为了做困难题而忽视基础,因此,如果简单题得到的总分,不超过给定的分值限制 lns="http://www.w3.org/1998/Math/MathML">M 时,做困难题回答正确不得分,而回答错误一样倒扣 lns="http://www.w3.org/1998/Math/MathML">20 分。同时,为了照顾学生情绪,如果学生所有题累计的得分小于 lns="http://www.w3.org/1998/Math/MathML">0,则按照 lns="http://www.w3.org/1998/Math/MathML">0 分计算。

现在给定试卷中简单题的题数 lns="http://www.w3.org/1998/Math/MathML">a,困难题的题数 lns="http://www.w3.org/1998/Math/MathML">b,以及小 A 做对的简单题的题数 lns="http://www.w3.org/1998/Math/MathML">c,困难题的题数 lns="http://www.w3.org/1998/Math/MathML">d,以及给定的分值限制 lns="http://www.w3.org/1998/Math/MathML">M。问,小 A 最终能获得几分。

Input

输入一行,五个正整数 lns="http://www.w3.org/1998/Math/MathML">a,b,c,d,M

,分别表示试卷中简单题的题数、困难题的题数、小 A 做对的简单题的题数、小 A 做对的困难题的题数以及给定的分值限制。

【数据范围】

对于所有数据,保证:lns="http://www.w3.org/1998/Math/MathML">1a,b,c,d100lns="http://www.w3.org/1998/Math/MathML">1calns="http://www.w3.org/1998/Math/MathML">1dblns="http://www.w3.org/1998/Math/MathML">1M500


Output

输出一行一个整数,表示小 A 最终能获得几分。

Sample Input Copy

10 5 7 4 30

Sample Output Copy

95

HINT

隐藏样例1。输入 10 5 7 4 40 输出 15

隐藏样例2。输入 10 5 7 1 40 输出 0


  • 对于样例 lns="http://www.w3.org/1998/Math/MathML">1,小 A 做对了 lns="http://www.w3.org/1998/Math/MathML">7 道简单题获得了 lns="http://www.w3.org/1998/Math/MathML">35 分,超过了给定的 lns="http://www.w3.org/1998/Math/MathML">30 分限制,因此会正常计算困难题的得分。小 A 做对了 lns="http://www.w3.org/1998/Math/MathML">4 个困难题获得 lns="http://www.w3.org/1998/Math/MathML">80 分,但是错了一道要倒扣 lns="http://www.w3.org/1998/Math/MathML">20 分,因此合计为 lns="http://www.w3.org/1998/Math/MathML">35+8020=95 分。
  • 对于样例 lns="http://www.w3.org/1998/Math/MathML">2,小 A 做对了 lns="http://www.w3.org/1998/Math/MathML">7 道简单题获得了 lns="http://www.w3.org/1998/Math/MathML">35 分,并未超过给定的阈值 lns="http://www.w3.org/1998/Math/MathML">40,因此只计算做错困难题的倒扣分,合计为 lns="http://www.w3.org/1998/Math/MathML">3520=15 分。
  • 对于样例 lns="http://www.w3.org/1998/Math/MathML">3,与样例 lns="http://www.w3.org/1998/Math/MathML">2 一样,只计算做错困难题的倒扣分。小 A 只做对了 lns="http://www.w3.org/1998/Math/MathML">1 个困难题,要倒扣 lns="http://www.w3.org/1998/Math/MathML">80 分。此时小 A 累计的得分小于 lns="http://www.w3.org/1998/Math/MathML">0,则按照 lns="http://www.w3.org/1998/Math/MathML">0 分作为最后的分值。

Source/Category