思考题 for stupid myself

A well-known task

Given N segments with weight .

Now you want to choose some segments so that is maximum.

means the number of integers in the set . K is decided by yourself.

Example

Input
{[1,5],w=3}
{[2,4],w=5}
{[3,5],w=1}
Output

Explain
choose 1 -> [1,5]
choose 2 -> [2,4]
choose 3 -> [3,5]
choose 1,2 -> [2,4]
choose 1,3 -> [3,5]
choose 2,3 -> [3,4]
choose 1,2,3 -> [3,4]

Constriants

Subtask 1(10%):
Subtask 2(20%):
Subtask 3(30%):
Subtask 4(40%):

The author can get 60%(30%)

Orange boy will get AC quickly!

Slow (or Maybe Wrong) Solution By Weak XGN

Sort the segments by L. Then for each L we choose all segments with then we sort the chosen segments by R. Then we brute force which segments to choose.
Time Complexity is

Proof Required