A9225 | Dima and Hares
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more.
Dima felt so grateful to Inna about the present that he decided to buy her $n$ hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to $n$ from left to right and started feeding them with carrots. Inna was determined to feed each hare exactly once. But in what order should she feed them?
Inna noticed that each hare radiates joy when she feeds it. And the joy of the specific hare depends on whether Inna fed its adjacent hares before feeding it. Inna knows how much joy a hare radiates if it eats when either both of his adjacent hares are hungry, or one of the adjacent hares is full (that is, has been fed), or both of the adjacent hares are full. Please note that hares number 1 and $n$ don't have a left and a right-adjacent hare correspondingly, so they can never have two full adjacent hares.
Help Inna maximize the total joy the hares radiate. :)
Dima felt so grateful to Inna about the present that he decided to buy her $n$ hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to $n$ from left to right and started feeding them with carrots. Inna was determined to feed each hare exactly once. But in what order should she feed them?
Inna noticed that each hare radiates joy when she feeds it. And the joy of the specific hare depends on whether Inna fed its adjacent hares before feeding it. Inna knows how much joy a hare radiates if it eats when either both of his adjacent hares are hungry, or one of the adjacent hares is full (that is, has been fed), or both of the adjacent hares are full. Please note that hares number 1 and $n$ don't have a left and a right-adjacent hare correspondingly, so they can never have two full adjacent hares.
Help Inna maximize the total joy the hares radiate. :)
输入格式
The first line of the input contains integer $n$ $(1<=n<=3000)$ — the number of hares. Then three lines follow, each line has $n$ integers. The first line contains integers $a_{1}$ $a_{2}$ $...$ $a_{n}$ . The second line contains $b_{1},b_{2},...,b_{n}$ . The third line contains $c_{1},c_{2},...,c_{n}$ . The following limits are fulfilled: $0<=a_{i},b_{i},c_{i}<=10^{5}$ .
Number $a_{i}$ in the first line shows the joy that hare number $i$ gets if his adjacent hares are both hungry. Number $b_{i}$ in the second line shows the joy that hare number $i$ radiates if he has exactly one full adjacent hare. Number $с_{i}$ in the third line shows the joy that hare number $i$ radiates if both his adjacent hares are full.
Number $a_{i}$ in the first line shows the joy that hare number $i$ gets if his adjacent hares are both hungry. Number $b_{i}$ in the second line shows the joy that hare number $i$ radiates if he has exactly one full adjacent hare. Number $с_{i}$ in the third line shows the joy that hare number $i$ radiates if both his adjacent hares are full.
输出格式
In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.
输入输出样例
输入 #1
4 1 2 3 4 4 3 2 1 0 1 1 0
输出 #1
13
输入 #2
7 8 5 7 6 1 8 9 2 7 9 5 4 3 1 2 3 3 4 1 1 3
输出 #2
44
输入 #3
3 1 1 1 1 2 1 1 1 1
输出 #3
4
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted