A945 | Greedy Pie Eaters--Platinum
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Farmer John has $M$ cows, conveniently labeled $1 \ldots M$, who enjoy the
occasional change of pace from eating grass. As a treat for the cows, Farmer
John has baked $N$ pies ($1 \leq N \leq 300$), labeled $1 \ldots N$. Cow $i$
enjoys pies with labels in the range $[l_i, r_i]$ (from $l_i$ to $r_i$
inclusive), and no two cows enjoy the exact same range of pies. Cow $i$ also
has a weight, $w_i$, which is an integer in the range $1 \ldots 10^6$.
Farmer John may choose a sequence of cows $c_1,c_2,\ldots, c_K,$ 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 $c_i$'s turn to eat, she will
consume all of the pies that she enjoys --- that is, all remaining pies in the
interval $[l_{c_i},r_{c_i}]$. 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 ($w_{c_1}+w_{c_2}+\ldots+w_{c_K}$) of a sequence
$c_1,c_2,\ldots, c_K$ for which each cow in the sequence eats at least one
pie.
occasional change of pace from eating grass. As a treat for the cows, Farmer
John has baked $N$ pies ($1 \leq N \leq 300$), labeled $1 \ldots N$. Cow $i$
enjoys pies with labels in the range $[l_i, r_i]$ (from $l_i$ to $r_i$
inclusive), and no two cows enjoy the exact same range of pies. Cow $i$ also
has a weight, $w_i$, which is an integer in the range $1 \ldots 10^6$.
Farmer John may choose a sequence of cows $c_1,c_2,\ldots, c_K,$ 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 $c_i$'s turn to eat, she will
consume all of the pies that she enjoys --- that is, all remaining pies in the
interval $[l_{c_i},r_{c_i}]$. 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 ($w_{c_1}+w_{c_2}+\ldots+w_{c_K}$) of a sequence
$c_1,c_2,\ldots, c_K$ for which each cow in the sequence eats at least one
pie.
输入格式
* Test cases 2-5 satisfy $N\le 50$ and $M\le 20$.
* Test cases 6-9 satisfy $N\le 50.$
* Test cases 6-9 satisfy $N\le 50.$
输出格式
The first line contains two integers $N$ and $M$ $\left(1\le M\le
\frac{N(N+1)}{2}\right)$.
The next $M$ lines each describe a cow in terms of the integers $w_i, l_i$,
and $r_i$.
\frac{N(N+1)}{2}\right)$.
The next $M$ lines each describe a cow in terms of the integers $w_i, l_i$,
and $r_i$.
输入输出样例
输入 #1
Print the maximum possible total weight of a valid sequence.
输出 #1
2 2 100 1 2 100 1 1
200
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted