#P5851. [USACO19DEC] Greedy Pie Eaters P
[USACO19DEC] Greedy Pie Eaters P
题目背景
Farmer John has cows, conveniently labeled , who enjoy the occasional change of pace from eating grass. As a treat for the cows, Farmer John has baked pies (), labeled . Cow enjoys pies with labels in the range (from to inclusive), and no two cows enjoy the exact same range of pies. Cow also has a weight, , which is an integer in the range .
Farmer John may choose a sequence of cows after which the selected cows will take turns eating in that order. Unfortunately, the cows don't know how to share! When it is cow 's turn to eat, she will consume all of the pies that she enjoys --- that is, all remaining pies in the interval . Farmer John would like to avoid the awkward situation occurring when it is a cows turn to eat but all of the pies she enjoys have already been consumed. Therefore, he wants you to compute the largest possible total weight () of a sequence for which each cow in the sequence eats at least one pie.
题目描述
Farmer John 有 头奶牛,为了方便,编号为 。这些奶牛平时都吃青草,但是喜欢偶尔换换口味。Farmer John 一天烤了 个派请奶牛吃,这 个派编号为 。第 头奶牛喜欢吃编号在 中的派(包括两端),并且没有两头奶牛喜欢吃相同范围的派。第 头奶牛有一个体重 ,这是一个在 中的正整数。
Farmer John 可以选择一个奶牛序列 ,并让这些奶牛按这个顺序轮流吃派。不幸的是,这些奶牛不知道分享!当奶牛 吃派时,她会把她喜欢吃的派都吃掉——也就是说,她会吃掉编号在 中所有剩余的派。Farmer John 想要避免当轮到一头奶牛吃派时,她所有喜欢的派在之前都被吃掉了这样尴尬的情况。因此,他想让你计算,要使奶牛按 的顺序吃派,轮到这头奶牛时她喜欢的派至少剩余一个的情况下,这些奶牛的最大可能体重()是多少。
输入格式
第一行包含两个正整数 ;
接下来 行,每行三个正整数 。
输出格式
输出对于一个合法的序列,最大可能的体重值。
2 2
100 1 2
100 1 1
200
提示
样例解释
在这个样例中,如果奶牛 先吃,那么奶牛 就吃不到派了。然而,先让奶牛 吃,然后奶牛 只吃编号为 的派,仍可以满足条件。
对于全部数据,$1 \le N \le 300,1 \le M \le \dfrac{N(N-1)}{2},1 \le l_i,r_i \le N,1 \le w_i \le 10^6$。
数据范围
对于测试点 ,满足 ;
对于测试点 ,满足 。
USACO 2019 December 铂金组T1