#P5621. [DBOI2019] 德丽莎世界第一可爱

[DBOI2019] 德丽莎世界第一可爱

Description

There are nn Honkai beasts. Each Honkai beast has five attributes: health, energy, attack, defense, and collapse energy. For the ii-th Honkai beast, denote these five attributes by their initials as HiH_i, EiE_i, AiA_i, DiD_i, and CiC_i.

Theresa may choose any Honkai beast to attack first. If she kills Honkai beast ii, she gains CiC_i cuteness points. Since Theresa gets stronger as she fights, the next Honkai beast jj she fights must satisfy HjHiH_j \ge H_i, EjEiE_j \ge E_i, AjAiA_j \ge A_i, and DjDiD_j \ge D_i.

Please help Theresa compute the maximum total cuteness points she can obtain.

Input Format

The first line contains a positive integer nn.

The next nn lines: on line i+1i+1, there are five integers Hi,Ei,Ai,Di,CiH_i, E_i, A_i, D_i, C_i, representing the attribute values of the ii-th Honkai beast.

Output Format

Output one integer, representing the maximum cuteness points (she must kill at least one Honkai beast). The answer is guaranteed not to exceed the range of long long (26312^{63}-1).

5
1 9 3 6 233
0 8 3 7 666
-3 9 4 2 810
2 3 3 3 -100
1 8 8 9 603
1269

Hint

Subtask ID nn \le Score
11 100100 2020
22 10410^4
33 5×1045 \times 10^4 6060

For 100%100\% of the testdata, it holds that 1n500001 \le n \le 50000, and 109Hi,Ei,Ai,Di,Ci109-10^9 \le H_i, E_i, A_i, D_i, C_i \le 10^9.

Translated by ChatGPT 5