5520: 暑期营第九天 摘果实

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Input

Output

Sample Input Copy

5
0 9 3
1 2 2
5 3 2
5 1 4
2 3 3

Sample Output Copy

20

HINT