CF1106E Lunar New Year and Red Envelopes

题目描述

新年就要到啦,Bob打算去要很多红包!不过要红包是一件很费时间的事情。 我们假设从第$1$秒开始共有$n$秒,第$i$个红包可以在第$s_i$到$t_i$秒(包括端点)收集,并且其中有$w_i$元。如果Bob拿了第$i$个红包,那么他直到第$d_i$秒后(不包括$d_i$)才可以继续收集红包。其中$s_i \leq t_i \leq d_i$. Bob是一个贪心的人,他贪心地收集红包:如果他在第$x$秒有红包可以收集,他就会选择其中钱最多的那个红包。如果这样的红包有多个,他就选$d$**最大**的那个红包。如果还是有多个选择,他就随便拿一个。 然而他的女儿Alice并不想他的爸爸拿到太多钱。她可以干扰Bob最多$m$次。如果Alice在第$x$秒干扰Bob,在这一秒Bob就不能收集红包,然后下一秒Bob会继续用自己的策略收集。 现在请你求出如果Alice采用最优的策略,Bob能拿到的最少钱数。

输入格式

输出格式

说明/提示

In the first sample, Alice has no chance to disturb Bob. Therefore Bob will collect the coins in the red envelopes at time $ 1 $ and $ 5 $ , collecting $ 13 $ coins in total. In the second sample, Alice should disturb Bob at time $ 1 $ . Therefore Bob skips the first envelope, collects the second one and can not do anything after that. So the answer is $ 2 $ .