{"problem":{"name":"Ex - Snuke Panic (2D)","description":{"content":"Takahashi is trying to catch many Snuke. There are some pits in a two-dimensional coordinate plane, connected to Snuke's nest. Now, $N$ Snuke will appear from the pits. It is known that the $i$\\-th Sn","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":5000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc266_h"},"statements":[{"statement_type":"Markdown","content":"Takahashi is trying to catch many Snuke.\nThere are some pits in a two-dimensional coordinate plane, connected to Snuke's nest.\nNow, $N$ Snuke will appear from the pits. It is known that the $i$\\-th Snuke will appear from the pit at coordinates $(X_i,Y_i)$ at time $T_i$, and its size is $A_i$.\nTakahashi is at coordinates $(0,0)$ at time $0$ and can do the following two kinds of moves.\n\n*   Move at a speed of at most $1$ in the $x$\\-direction (positive or negative).\n*   Move at a speed of at most $1$ in the **positive** $y$\\-direction.\n\nMoving in the negative $y$\\-direction is not allowed.\nHe can catch a Snuke appearing from a pit if and only if he is at the coordinates of that pit exactly when it appears.  \nThe time it takes to catch a Snuke is negligible.\nFind the maximum sum of the sizes of Snuke that Takahashi can catch by moving optimally.\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^5$\n*   $1 \\leq T_i \\leq 10^9$\n*   $0 \\leq X_i,Y_i \\leq 10^9$\n*   $1 \\leq A_i \\leq 10^9$\n*   The triples $(T_i,X_i,Y_i)$ are distinct.\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$T_1$ $X_1$ $Y_1$ $A_1$\n$T_2$ $X_2$ $Y_2$ $A_2$\n$\\vdots$\n$T_N$ $X_N$ $Y_N$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc266_h","tags":[],"sample_group":[["3\n1 0 0 100\n3 2 1 10\n5 3 1 1","101\n\nThe optimal strategy is as follows.\n\n*   Wait at coordinates $(0,0)$ to catch the first Snuke at time $1$.\n*   Go to coordinates $(3,1)$ to catch the third Snuke at time $5$.\n\nIt is impossible to catch both the first and second Snuke, so this is the best he can."],["2\n100 0 1 1\n200 1 0 10","10\n\nMoving in the negative $y$\\-direction is not allowed, so he cannot catch the first Snuke and then the second."],["10\n797829355 595605750 185676190 353195922\n913575467 388876063 395940406 533206504\n810900084 201398242 159760440 87027328\n889089200 220046203 85488350 325976483\n277429832 161055688 73308100 940778720\n927999455 429014248 477195779 174616807\n673419335 415891345 81019893 286986530\n989248231 147792453 417536200 219371588\n909664305 22150727 414107912 317441890\n988670052 140275628 468278658 67181740","1553741733"]],"created_at":"2026-03-03 11:01:14"}}