| Teamscode Summer 2023 Contest |
|---|
| Finished |
Because climate change is a hoax $$$^{\text{[citation needed]}}$$$, Alice has decided to enter the lucrative business of oil drilling. There are $$$n$$$ deposits of oil scattered across the $$$2$$$-d coordinate plane, numbered $$$1$$$ through $$$n$$$. The $$$i$$$-th deposit is at coordinate $$$(x_i, y_i)$$$ and has $$$w_i$$$ units of oil.
Alice can enclose some oil deposits with a perimeter to secure drilling rights. The profit from such a perimeter is the total amount of oil minus the cost of the perimeter. The cost of a perimeter of length $$$k$$$ is given by the expression $$$m\dot k+c$$$, where $$$m$$$ and $$$c$$$ are given constants. Help Alice find the maximum profit she can make.
Each test contains multiple testcases. The first line contains the number of testcases $$$t$$$ ($$$1\leq t\leq 20$$$). The description of the test cases follows.
The first line of each testcase contains three integers $$$n$$$,$$$m$$$,and $$$c$$$ ($$$1\leq n\leq 400$$$, $$$0\leq m,c\leq 10^9$$$) — the number of oil deposits and the parameters of the cost function, as described above.
The $$$i$$$-th of the next $$$n$$$ lines contains three integers $$$x_i,y_i,w_i$$$ ($$$\lvert x_i\rvert, \lvert y_i\rvert\leq 10^9, 1\leq w_i\leq 10^9$$$) — the location and amount of oil of the $$$i$$$-th deposit. Note that the positions of deposits may not be distinct.
It is guaranteed that the sum of $$$n$$$ over all testcases does not exceed $$$500$$$.
—
Testcases in subtasks are numbered $$$1$$$ to $$$40$$$ with samples skipped.
Test $$$1-6$$$: The sum of $$$n$$$ does not exceed $$$20$$$.
Test $$$7-12$$$: All $$$w_i$$$ have the same value.
Test $$$13-40$$$: No additional constraints.
The test are worth an alternating $$$2$$$ or $$$3$$$ points with samples skipped.
For each test case, print a single floating point value — the maximum profit that Alice can earn by building one perimeter.
Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$.
Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.
13 10 01 1 52 6 35 5 1
5.000000
32 2 01 1 1003 3 1004 0 01 1 12 4 14 2 14 4 13 1 1001 1 21 2 22 1 2
188.686292 4.000000 -97.414214
36 2 51 1 54 3 22 5 35 6 63 4 74 5 36 3 16 4 55 4 47 5 31 1 16 3 57 1 615 2 107 5 21 3 92 5 105 4 132 6 171 1 1111 2 33 4 34 2 126 9 12 7 110 8 33 3 81 5 1411 5 2
2.000000 5.000000 58.163779
Problem Idea: dutin Problem Preparation: dutin Occurrences: Advanced 11
| Name |
|---|


