Problem 3021 --Snowy Smile

3021: Snowy Smile

"
Time Limit $4$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $3$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
There are nn pirate chests buried in Byteland, labeled by 1,2,…,n1,2,…,n. The ii-th chest's location is (xi,yi)(xi,yi), and its value is wiwiwiwi can be negative since the pirate can add some poisonous gases into the chest. When you open the ii-th pirate chest, you will get wiwi 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.
The first line of the input contains an integer T(1≤T≤100)T(1≤T≤100), denoting the number of test cases. 

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

For the next nn lines, each line contains three integers xi,yi,wi(−109≤xi,yi,wi≤109)xi,yi,wi(−109≤xi,yi,wi≤109), denoting each pirate chest. 

It is guaranteed that ∑n≤10000∑n≤10000.
For each test case, print a single line containing an integer, denoting the maximum total value.
2
4
1 1 50
2 1 50
1 2 50
2 2 -500
2
-1 1 5
-1 1 1
100
6

推荐代码 查看3021 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$3732 $ms] 淡意的温柔 590727 2020-06-05 09:14:56
内存最少[$2648 $KB] 淡意的温柔 590727 2020-06-05 09:14:56
第一AC 淡意的温柔 590726 2020-06-05 09:13:35
第一挑战 淡意的温柔 588044 2020-05-27 09:30:58

赛题来源/所属竞赛 2019 Multi-University Training Contest 6 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛