#P12196. [NOISG 2025 Prelim] Lasers 2
[NOISG 2025 Prelim] Lasers 2
题目描述
Pavement has purchased a laser toy from Gohcart (who originally bought it from Rar the Cat). The toy features a grid of rows and columns. The rows of the grid are numbered to from top to bottom, and the columns of the grid are numbered to from left to right.
Each row contains exactly one locked sliding wall. Initially, the wall in the -th row spans columns to (-indexed), and can be unlocked for dollars. Once unlocked, it can be slid horizontally to any position along the -th row, as long as it is aligned to the edges of the grid. No part of the wall can leave the left or right edges of the toy.
Each column contains a downward-facing laser positioned at the top of the column. If any sliding wall is contained in the -th column, it will block the path of the laser in the -th column.
A possible toy with and is depicted in the diagram below:

Given a total budget of dollars, Pavement aims to maximise the number of lasers that are not blocked after optimally unlocking and sliding the walls. Determine the maximum number of unblocked lasers he can achieve.
输入格式
Your program must read from standard input.
The first line of input contains three space-separated integers and , describing the number of rows, the number of columns and the budget, respectively.
The next lines of input each contain three space-separated integers. The -th of these lines contains , and , describing the sliding wall in the -th row.
输出格式
Your program must print to standard output.
Output a single integer, the maximum number of unblocked lasers achievable.
3 10 10
2 5 9
1 3 1
4 7 10
6
10 10 50
8 8 0
3 3 0
6 6 2
7 7 9
1 1 50
5 5 21
6 6 4
10 10 4
10 10 3
10 10 3
9
4 17 0
2 4 1000000000
6 9 1000000000
8 13 1000000000
15 16 1000000000
4
提示
Subtasks
For all testcases, the input will satisfy the following bounds:
- for all
- for all
Your program will be tested on input instances that satisfy the following restrictions:
| Subtask | Marks | Additional constraints |
|---|---|---|
| Sample test cases | ||
| No additional constraints | ||
Sample Test Case 1 Explanation
This test case is valid for subtasks , and .
The laser toy in the above figure corresponds to this test case. Pavement can unlock the first and second sliding walls for a total cost of dollars. He can then slide the first sliding wall such that it spans columns to , and slide the second sliding wall to span columns to .

This leaves lasers (in columns , and ) unblocked, which is the maximum possible.
Sample Test Case 2 Explanation
This test case is valid for subtasks to .
Sample Test Case 3 Explanation
This test case is valid for subtasks , and .