Logo
(追記) (追記ここまで)

18590번 - Snowy Smile 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB1921049255.422%

문제

There are n pirate chests buried in Byteland, labeled by 1, 2, . . . , n. The i-th chest is located at point (xi, yi) on the plane, and its value is wi. Note that wi can be negative since the pirate can put some poisonous gases into the chest. When you open the i-th pirate chest, you will get wi value.

You want to make money from these pirate chests. You can select a rectangle such that its sides are all parallel to the coordinate axes, and then open all the chests inside this rectangle or on its border. Note that you must open all the chests within that range regardless of whether 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 maximum total value of a rectangle.

입력

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

Each test case starts with a line containing an integer n (1 ≤ n ≤ 2000), denoting the number of pirate chests.

Each of the next n lines contains three integers, xi, yi, and wi (−109 ≤ xi, yi, wi ≤ 109), describing the i-th pirate chest.

It is guaranteed that the sum of n in all test cases is at most 10 000.

출력

For each test case, print a single line containing a single integer: the maximum total value.

제한

예제 입력 1

2
4
1 1 50
2 1 50
1 2 50
2 2 -500
2
-1 1 5
-1 1 1

예제 출력 1

100
6

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2019 > Day 1: Songyang Chen Contest 2 E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /