![]() |
||||||||||
|
||||||||||
YJJ's SalesmanTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 4777 Accepted Submission(s): 1655 Problem Description YJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination. One day, he is going to travel from city A to southeastern city B. Let us assume that A is $(0, 0)$ on the rectangle map and B $(10^9, 10^9)$. YJJ is so busy so he never turn back or go twice the same way, he will only move to east, south or southeast, which means, if YJJ is at $(x, y)$ now $(0\le x\le 10^9,0\le y\le 10^9)$, he will only forward to $(x+1,y)$, $(x,y+1)$ or $(x+1,y+1)$. On the rectangle map from $(0,0)$ to $(10^9,10^9)$, there are several villages scattering on the map. Villagers will do business deals with salesmen from northwestern, but not northern or western. In mathematical language, this means when there is a village $k$ on $(x_k, y_k)$ $(1\le x_k\le10^9, 1\le y_k\le10^9)$, only the one who was from $(x_k-1,y_k-1)$ to $(x_k,y_k)$ will be able to earn $v_k$ dollars.(YJJ may get different number of dollars from different village.) YJJ has no time to plan the path, can you help him to find maximum of dollars YJJ can get. Input The first line of the input contains an integer $T$ $(1≤T≤10)$,which is the number of test cases. In each case, the first line of the input contains an integer $N$ $(1≤N≤10^5)$.The following $N$ lines, the $k$-th line contains 3 integers, $x_k, y_k, v_k$ $(0≤v_k≤10^3)$, which indicate that there is a village on $(x_k,y_k)$ and he can get $v_k$ dollars in that village. The positions of each village is distinct. Output The maximum of dollars YJJ can get. Sample Input
Sample Output
Source | ||||||||||
|