#B4052. Magic Energy Calculation
Magic Energy Calculation
Magic Energy Calculation
In this problem, you are given five parameters related to a magical event in the game "Didiwei". The parameters are:
type
: the energy type.A
: the attack value of the initiator.B
: the magic power of the initiator.C
: the physical resistance of the receiver.D
: the magic resistance of the receiver.
The energy value is computed as follows:
- If \( type = 0 \), then the energy is \( A+B \).
- If \( type = 1 \), then the energy is \( \max(A-C,0)+\max(B-D,0) \).
Here, \( \max(x,y) \) denotes the maximum of \( x \) and \( y \). Given the five parameters, calculate the magic energy.
inputFormat
The input consists of a single line containing five space-separated integers:
type
\( (0 \text{ or } 1) \)A
(initiator's attack)B
(initiator's magic power)C
(receiver's physical resistance)D
(receiver's magic resistance)
outputFormat
Output a single integer representing the computed energy value.
sample
0 3 4 5 6
7