#P9594. 「Daily OI Round 1」Memory
「Daily OI Round 1」Memory
Problem Description
Given line segments. Each segment is described by four positive integers , where are the endpoints of the segment, is the type (category) of the segment, and is the weight of the segment.
You need to select some segments such that the following condition is satisfied, and the total weight is maximized.
- For any two different segments , either holds, or .
Input Format
The first line contains a positive integer , representing the number of segments.
The next lines each contain four positive integers , describing the four parameters of a segment, with meanings as stated above.
Output Format
Output one integer in a single line, representing the maximum total weight that can be obtained.
5
2 9 1 1
3 9 1 10
4 8 1 10
5 6 3 1
7 9 3 10
21
10
1 2 2 8
2 4 2 2
6 10 3 5
2 8 2 4
5 9 2 7
1 1 1 10
2 8 2 2
1 7 3 7
8 9 2 4
5 7 3 3
29
Hint
Sample Explanation
For sample , the selected segments are segments . They are all of the same type, and the total weight is . It can be proven that this selection is optimal.
Constraints
This problem uses bundled testdata.
| Score | Special Property | ||||
|---|---|---|---|---|---|
| None | |||||
| A | |||||
| None |
- Special property A: There do not exist distinct positive integers such that .
For all testdata, it is guaranteed that , , , and .
Translated by ChatGPT 5