F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

YJJ's Salesman

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4661    Accepted Submission(s): 1633


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
1 3 1 1 1 1 2 2 3 3 1
 

Sample Output
3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-19 09:30:26, Gzip enabled