Convex Dombination

AtCoder
ID1202Contest_i
Time2000ms
Memory256MB
Difficulty
You are given $N$ distinct integer grid points $(X_i, Y_i) \ (i = 1, 2, \dots, N)$ in the plane, each of which has an integer score $P_i$. You can choose an arbitrary number of grid points among them under the following condition. Find the maximum value of the sum of the scores of chosen grid points. **Condition:** A grid point **dominated** by a **convex combination** of the chosen grid points must be chosen. That is, for each $k = 1, 2, \dots, N$, if there exists a tuple $(\lambda_1, \lambda_2, \dots, \lambda_N)$ of $N$ **nonnegative** reals with the following conditions, then $(X_k, Y_k)$ is chosen: * $\lambda_i > 0 \implies (X_i, Y_i)$ is chosen. * $\sum_{i=1}^N \lambda_i = 1.$ * $\sum_{i=1}^N \lambda_i X_i \geq X_k.$ * $\sum_{i=1}^N \lambda_i Y_i \geq Y_k.$ ## Constraints * $1 \leq N \leq 200$ * $1 \leq X_i \leq 10^9 \ \ (1 \leq i \leq N)$ * $1 \leq Y_i \leq 10^9 \ \ (1 \leq i \leq N)$ * $(X_i, Y_i) \neq (X_j, Y_j) \ \ (i \neq j)$ * $|P_i| \leq 10^7 \ \ (1 \leq i \leq N)$ ## Input The input is given from Standard Input in the following format: $N$ $X_1 \ Y_1 \ P_1$ $X_2 \ Y_2 \ P_2$ $\vdots$ $X_N \ Y_N \ P_N$ [samples]
Samples
Input #1
3
1 4 2
4 1 3
2 2 -4
Output #1
3

It is optimal to choose only $(X_2, Y_2) = (4, 1)$. If you choose $(X_1, Y_1) = (1, 4)$ in addition, then for example $\lambda_1 = 0.4$ and $\lambda_2 = 0.6$ satisfy
\\\[ \\lambda_1 + \\lambda_2 = 0.4 + 0.6 = 1\\\\\[1mm\] \\lambda_1 X_1 + \\lambda_2 X_2 = 0.4 \\times 1 + 0.6 \\times 4 = 2.8 \\geq 2 = X_3\\\\\[1mm\] \\lambda_1 Y_1 + \\lambda_2 Y_2 = 0.4 \\times 4 + 0.6 \\times 1 = 2.2 \\geq 2 = Y_3, \\\]
and hence $(X_3, Y_3) = (2, 2)$ must be chosen in addition, which decreases the sum of scores as a result.
Input #2
3
1 4 2
4 1 3
2 2 -1
Output #2
4

It is optimal to choose all the grid points.
Input #3
3
1 4 2
4 1 3
1 1 -6
Output #3
0

It is sometimes optimal to choose no grid point.
API Response (JSON)
{
  "problem": {
    "name": "Convex Dombination",
    "description": {
      "content": "You are given $N$ distinct integer grid points $(X_i, Y_i) \\ (i = 1, 2, \\dots, N)$ in the plane, each of which has an integer score $P_i$. You can choose an arbitrary number of grid points among them ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "1202Contest_i"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given $N$ distinct integer grid points $(X_i, Y_i) \\ (i = 1, 2, \\dots, N)$ in the plane, each of which has an integer score $P_i$. You can choose an arbitrary number of grid points among them ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments