[USACO19DEC] Greedy Pie Eaters P 区间dp
题目背景
Farmer John has MM cows, conveniently labeled 1…M1…M, who enjoy the occasional change of pace from eating grass. As a treat for the cows, Farmer John has baked NN pies (1≤N≤3001≤N≤300), labeled 1…N1…N. Cow ii enjoys pies with labels in the range [li,ri][li,ri] (from lili to riri inclusive), and no two cows enjoy the exact same range of pies. Cow ii also has a weight, wiwi, which is an integer in the range 1…1061…106.
Farmer John may choose a sequence of cows c1,c2,…,cK,c1,c2,…,cK, 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 cici's turn to eat, she will consume all of the pies that she enjoys --- that is, all remaining pies in the interval [lci,rci][lci,rci]. 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 (wc1+wc2+…+wcKwc1+wc2+…+wcK) of a sequence c1,c2,…,cKc