시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
서브태스크 참고 (추가 시간 없음) | 1024 MB | 10 | 6 | 6 | 66.667% |
In a forest of the magical world, there lies a garden full of magical creatures. The garden has plenty of flowers which are not just beautiful but also a source of energy for butterflies.
Consider the garden a 2D plane where the X-axis represents the ground, and the Y-axis represents the altitude. There are plants of infinite height on every non-negative integral point on the X-axis. There are $\mathbf{N}$ flowers in the garden, where the $i$-th flower is on the point ($\mathbf{X_i}$, $\mathbf{Y_i}$) with the nectar of some energy value $\mathbf{C_i}$.
Our cute little butterfly wants as much energy as possible to become strong. By going to the same position of a flower, the butterfly can consume its nectar and gain that flower's energy value. Each flower's nectar can only be consumed once.
The butterfly is initially at point $(0, 10^{18})$ with $0$ units of energy and facing towards the right. At any point, the butterfly can:
We know our butterfly is lazy, and it hates to move upwards during the journey. So, for this problem, we will assume that going upwards is not allowed. Also, energy can be negative at any point. Negative energy means the butterfly has spent more energy than it obtained from the flowers.
Find the maximum energy our cute butterfly can achieve.
The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ test cases follow.
The first line of each test case contains two integers, $\mathbf{N}$ and $\mathbf{E}$: the number of flowers and the energy required per turn, respectively.
The next $\mathbf{N}$ lines describe the flowers. The $i$-th line contains three integers, $\mathbf{X_i}$, $\mathbf{Y_i}$ and $\mathbf{C_i}$: the position and the energy value of the $i$-th flower, respectively.
For each test case, output one line containing Case #x: y
, where $x$ is the test case number (starting from 1) and $y$ is the maximum overall energy our cute butterfly can achieve.
시간 제한: 20 초
시간 제한: 40 초
시간 제한: 60 초
2 4 10 1 1 2 1 2 2 2 1 2 2 2 2 6 5 1 1 4 1 3 1 3 4 5 4 3 2 5 2 1 3 2 10
Case #1: 6 Case #2: 17
In sample test case #1, there are $\mathbf{N} = 4$ flowers and $\mathbf{E} = 10$. To maximise the overall energy our butterfly can move in this way:
Hence, the total energy the butterfly got in this way is $6$ units.
In sample test case #2, there are $\mathbf{N} = 6$ flowers and $\mathbf{E} = 5$. To maximise the overall energy our butterfly can move in this way:
Hence, the total energy the butterfly got in this way is $17$ units.
Contest > Google > Kick Start > Google Kick Start 2022 > Round G D번