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

18699번 - Darts Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB203233.333%

문제

Darts is a fun game, in the game you shoot several darts on a board and you get a score for each dart based on its location. The game in this problem is a bit different.

The board in this problem can be considered as an infinite 2-dimensional plane, and you have already shot N darts. For each dart, you are given its location on the board as a point (X, Y ), and also for each dart you are given a score which you will get if we count this dart, this score can be negative or positive, and multiple darts can be at the exact same location with even different scores.

Here’s how the scoring happens. After shooting the N darts, you are required to draw a square on this plane, the length of the square side must be L, also the point (0, 0) must be exactly at the center of the square, but you can rotate the square in any way you want. Then you will get the score for each dart which is inside that square or on its boundaries.

Note that you can rotate the square only once before considering any darts.

Given the location and the score for each dart and the value of L, your task is to draw a square that gives you the maximum possible score (it’s okay if the square doesn’t contain any darts).

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T (1 ≤ T ≤ 100) representing the number of test cases. Followed by T test cases.

Each test case starts with a line containing an integer N (1 ≤ N ≤ 105) representing the number of darts, followed by a space then an integer L (1 ≤ L ≤ 105) which is the length of the square side.

Followed by N lines, each line will contain 3 integers separated by a space, ‘X Y S’, which means there’s a dart at point (X, Y) and will give you score S if it’s counted (−105 ≤ X, Y, S ≤ 105).

출력

For each test case print a single line containing the maximum score you can get after drawing the square.

제한

예제 입력 1

2
5 8
4 5 100
3 3 4
-2 -2 -3
-1 1 2
4 -1 -101
7 10
1 1 -10
-1 1 -10
1 -1 -10
-1 -1 -10
0 1 -10
1 0 -10
2 2 -1000

예제 출력 1

3
-1060

힌트

The following image represents the first sample test case, there’s no way to take the point which gives score 100, but we can rotate the square little bit such that it no longer includes the point which gives score -101.

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2017 Arab Collegiate Programming Contest G번

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

출처

대학교 대회

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

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