A868 | Drought--Gold
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
The grass has dried up in Farmer John's pasture due to a drought. After hours
of despair and contemplation, FJ comes up with the brilliant idea of
purchasing corn to feed his precious cows.
FJ鈥檚 $N$ ($1 \leq N \leq 100$) cows are arranged in a line such that the $i$th
cow in line has a non-negative integer hunger level of $h_i$. As FJ鈥檚 cows are
social animals and insist on eating together, the only way FJ can decrease the
hunger levels of his cows is to select two adjacent cows $i$ and $i+1$ and
feed each of them a bag of corn, causing each of their hunger levels to
decrease by one.
FJ wants to feed his cows until all of them have the same non-negative hunger
level. Although he doesn't know his cows' exact hunger levels, he does know an
upper bound on the hunger level of each cow; specifically, the hunger level
$h_i$ of the $i$-th cow is at most $H_i$ ($0\le H_i\le 1000$).
Your job is to count the number of $N$-tuples of hunger levels
$[h_1,h_2,\ldots,h_N]$ that are consistent with these upper bounds such that
it is possible for FJ to achieve his goal, modulo $10^9+7$.
of despair and contemplation, FJ comes up with the brilliant idea of
purchasing corn to feed his precious cows.
FJ鈥檚 $N$ ($1 \leq N \leq 100$) cows are arranged in a line such that the $i$th
cow in line has a non-negative integer hunger level of $h_i$. As FJ鈥檚 cows are
social animals and insist on eating together, the only way FJ can decrease the
hunger levels of his cows is to select two adjacent cows $i$ and $i+1$ and
feed each of them a bag of corn, causing each of their hunger levels to
decrease by one.
FJ wants to feed his cows until all of them have the same non-negative hunger
level. Although he doesn't know his cows' exact hunger levels, he does know an
upper bound on the hunger level of each cow; specifically, the hunger level
$h_i$ of the $i$-th cow is at most $H_i$ ($0\le H_i\le 1000$).
Your job is to count the number of $N$-tuples of hunger levels
$[h_1,h_2,\ldots,h_N]$ that are consistent with these upper bounds such that
it is possible for FJ to achieve his goal, modulo $10^9+7$.
输入格式
The first line contains $N$.
The second line contains $H_1,H_2,\ldots,H_N$.
The second line contains $H_1,H_2,\ldots,H_N$.
输出格式
The number of $N$-tuples of hunger levels modulo $10^9+7$.
输入输出样例
输入 #1
3 9 11 7
输出 #1
241
There are $(9+1)\cdot (11+1)\cdot (7+1)$ $3$-tuples $h$ that are consistent
with $H$.
One of these tuples is $h=[8,10,5]$. In this case, it is possible to make all
cows have equal hunger values: give two bags of corn to both cows $2$ and $3$,
then give five bags of corn to both cows $1$ and $2$, resulting in each cow
having a hunger level of $3$.
Another one of these tuples is $h=[0,1,0]$. In this case, it is impossible to
make the hunger levels of the cows equal.
with $H$.
One of these tuples is $h=[8,10,5]$. In this case, it is possible to make all
cows have equal hunger values: give two bags of corn to both cows $2$ and $3$,
then give five bags of corn to both cows $1$ and $2$, resulting in each cow
having a hunger level of $3$.
Another one of these tuples is $h=[0,1,0]$. In this case, it is impossible to
make the hunger levels of the cows equal.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted