#P5583. 「SWTR-1」Ethan and Sets
「SWTR-1」Ethan and Sets
Description
has sets of numbers. Each set has the following properties:
ID: The ID of the -th set is .
Size: The size of the -th set is .
Magic power: The magic power of the -th set is .
Numbers: The -th set contains numbers .
In Ethan's world, there are only numbers in total: from to .
has special feelings about numbers. Among these numbers, there are numbers that he likes, namely . The remaining numbers are those he does not like.
Now wants to delete some sets. More precisely, he wants to choose an interval and delete all sets whose IDs are outside this interval.
-
He wants the remaining sets to contain all the numbers he likes.
-
Also, among the remaining sets, the total count of numbers he does not like should be as small as possible (note: this count means occurrences. For example, if is a number that does not like, and there are occurrences of in the remaining sets, then it counts as disliked numbers).
-
If there are multiple intervals that satisfy the above, he wants the sum of magic power of the remaining sets to be as large as possible.
Find an interval that meets the requirements. If there is no solution, output . If there are multiple solutions, output any one.
Input Format
The first line contains three integers .
The second line contains integers .
Lines to : each line starts with two integers , followed by integers .
Output Format
Output one line. If there is no solution, output . Otherwise, output two integers .
5 7 4
1 3 4 5
3 3 4 6 5
4 2 1 5
2 3 1 7 3
5 2 2 4
6 6 3 5 4 6 1 7
2 4
2 3 2
1 2
4 1 1
4 2 1 3
-1
4 3 2
1 2
1 1 3
1 2 1 2
1 1 2
1 3 1 2 3
2 3
Hint
Sample Explanation:
In sample , can choose . Then the remaining sets contain all the numbers he likes, and there are only occurrences of numbers he does not like in these sets.
In sample , there is no valid solution.
Constraints:
This problem uses subtasks.
Subtask 1: , .
Subtask 2: , .
Subtask 3: $1 \leq n \leq 3000, 1 \leq m \leq 1000, 1 \leq t_i \leq 10^9$, .
Translated by ChatGPT 5
京公网安备 11011102002149号