#P5621. Maximum Cuteness Value
Maximum Cuteness Value
Maximum Cuteness Value
There are \( n \) Collapsing Beasts, each with five attributes: \( health \) (生命力), \( energy \) (能量力), \( attack \) (攻击力), \( defense \) (防御力), and \( collapse \) (崩坏能). Delirisa can choose any beast to attack. After defeating beast \( i \), she gains \( collapse[i] \) cuteness value. Since she gets more experienced as she fights, the next beast \( j \) she attacks must satisfy the following conditions:
[ \begin{aligned} health[j] &\geq health[i],\ energy[j] &\geq energy[i],\ attack[j] &\geq attack[i],\ defense[j] &\geq defense[i]. \end{aligned} ]
Calculate the maximum total cuteness value she can obtain.
inputFormat
The first line contains an integer \( n \), representing the number of beasts. The next \( n \) lines each contain five integers: \( health \), \( energy \), \( attack \), \( defense \), and \( collapse \), separated by spaces.
outputFormat
Output a single integer --- the maximum total cuteness value Delirisa can obtain.
sample
3
1 2 3 4 5
2 3 4 5 6
1 1 1 1 1
12