#P10784. 【MX-J1-T4】『FLA - III』Wrestle
【MX-J1-T4】『FLA - III』Wrestle
Background
Original problem link: https://oier.team/problems/J1D.
At the end of 2022, the pandemic kept most students of a certain well-known (yet somehow unknown) school in Northwest China at home for online classes. Student An still did not know that his showdown with the Chinese teacher had already begun quietly—he slept through both morning reading and Chinese class every day.
Student An was used to getting up, getting dressed, and sleeping in front of the camera. The camera could only capture half of his shoulder, so even if it was forced on, it would not reveal that he was sleeping. Also, no teacher had ever forced him to turn on his camera. But on this unusual morning, the Chinese teacher turned on his camera. It was morning reading time. He was woken up in a daze by the teacher’s “caring” voice, but it was too late—the teacher was already angry. Student An decided to pretend that his network was lagging, to calm the teacher down.
The teacher was angry. During certain time intervals after Student An woke up, she would call his real name; during the other time intervals, she would wait for his response. At the same time, Student An needed to create the illusion of network lag: during certain time intervals, he could check devices or call the teacher; during the other time intervals, he would stay still or randomly flash in the video. His actions during those time intervals are called a performance. Your task is to help Student An maximize the performance time without angering the teacher.
Because Student An is really too “abstract,” the original statement was also made very “abstract” by him. Here, only the formal statement is provided.
Problem Description
You are given three positive integers and two sets of segments. The first set has weights and contains red segments; the second set has no weights and contains blue segments. These segments lie on the same number line.
-
Use three positive integers to represent a red segment that covers from the -th integer point on the number line to the -th integer point, with weight . It is guaranteed that any integer point on the number line is covered by at most one red segment.
-
Use two positive integers to represent a blue segment that covers from the -th integer point on the number line to the -th integer point, with no weight. It is guaranteed that any integer point on the number line is covered by at most one blue segment.
If a red segment covers from the -th integer point to the -th integer point, and a blue segment covers from the -th integer point to the -th integer point, and , then these two segments are considered to intersect. Their intersection contains all integer points from the -th integer point to the -th integer point.
You may choose some blue segments. A selection is legal if and only if it satisfies all of the following conditions:
-
Each red segment given in the input intersects with at most blue segment that you choose.
-
The sum of weights of all red segments that intersect with the blue segments you choose does not exceed .
When the selection is legal, what is the maximum possible number of integer points that can be contained in the intersection between the blue segments you choose and all red segments?
Input Format
The first line contains three positive integers .
The next lines: the -th line contains three positive integers , describing a red segment.
The next lines: the -th line contains two positive integers , describing a blue segment.
It is guaranteed that any integer point on the number line is covered by at most one red segment. It is guaranteed that any integer point on the number line is covered by at most one blue segment.
Output Format
Output one integer in a single line, representing the answer.
2 3 23
7 18 7
63 71 2
77 86
13 19
63 71
15
4 5 7
59 65 7
39 42 1
43 51 2
19 33 2
14 25
71 81
6 11
59 69
83 92
7
4 8 45
80 94 22
60 67 2
35 44 45
7 14 5
82 86
2 3
58 63
48 50
73 80
25 45
11 19
93 94
13
Hint
Sample Explanation #1

As shown in the figure, choose the -nd and the -rd blue segments in the input.
The -nd blue segment intersects with the -st red segment, and the intersection contains all integer points from the -th to the -th; the -rd blue segment intersects with the -nd red segment, and the intersection contains all integer points from the -th to the -th.
The -st red segment intersects only with the -nd blue segment, and the -nd red segment intersects only with the -rd blue segment. The total weight of red segments that intersect with the selected blue segments is , so the selection is legal. Therefore, the answer is .
Constraints
This problem uses bundled testdata.
| Subtask | Score | ||||
|---|---|---|---|---|---|
| #1 | |||||
| #2 | |||||
| #3 | |||||
| #4 | |||||
For of the testdata, , , , , , . It is guaranteed that any integer point on the number line is covered by at most one red segment. It is guaranteed that any integer point on the number line is covered by at most one blue segment.
Translated by ChatGPT 5