Snowy Smile

TimeLimit:4000MS  MemoryLimit:524288KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

There are n pirate chests buried in Byteland, labeled by 1,2,...,n. The i-th chest's location is (x_i,y_i), and its value is w_i, w_i can be negative since the pirate can add some poisonous gases into the chest. When you open the i-th pirate chest, you will get w_i value.

You want to make money from these pirate chests. You can select a rectangle, the sides of which are all paralleled to the axes, and then all the chests inside it or on its border will be opened. Note that you must open all the chests within that range regardless of their values are positive or negative. But you can choose a rectangle with nothing in it to get a zero sum.

Please write a program to find the best rectangle with maximum total value.

Input

The first line of the input contains an integer T(1≤T≤100), denoting the number of test cases.

In each test case, there is one integer n(1≤n≤2000) in the first line, denoting the number of pirate chests.

For the next n lines, each line contains three integers x_i,y_i,w_i(-10^9≤x_i,y_i,w_i≤10^9), denoting each pirate chest.

It is guaranteed that image.png.

Output
For each test case, print a single line containing an integer, denoting the maximum total value.
SampleInput
2
4
1 1 50
2 1 50
1 2 50
2 2 -500
2
-1 1 5
-1 1 1
SampleOutput
100
6
Submit
题目统计信息详细
总AC数2
通过人数2
尝试人数3
总提交量5
AC率40.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: