欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1195C.Basketball Exercise
Basketball Exercise
CF1195C · Basketball Exercise
- 难度:1400
- 标签:dp
- 链接:https://codeforces.com/problemset/problem/1195/C
- 时间限制:2 seconds 内存限制:256 megabytes
- 出现位置:Day01-复杂度-STL-字符串-位运算/选做
英文原题面
Statement
Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. students have come to Demid's exercise session, and he lined up them into two rows of the same size (there are exactly people in each row). Students are numbered from to in each row in order from left to right.
Now Demid wants to choose a team to play basketball. He will choose players from left to right, and the index of each chosen player (excluding the first one taken) will be strictly greater than the index of the previously chosen player. To avoid giving preference to one of the rows, Demid chooses students in such a way that no consecutive chosen students belong to the same row. The first student can be chosen among all students (there are no additional constraints), and a team can consist of any number of students. Demid thinks, that in order to compose a perfect team, he should choose students in such a way, that the total height of all chosen students is maximum possible. Help Demid to find the maximum possible total height of players in a team he can choose.
Input
The first line of the input contains a single integer () — the number of students in each row. The second line of the input contains integers (), where is the height of the -th student in the first row. The third line of the input contains integers (), where is the height of the -th student in the second row.
Output
Print a single integer — the maximum possible total height of players in a team Demid can choose.
样例
样例 1
输入:
5
9 3 5 7 3
5 8 1 4 5
输出:
29
样例 2
输入:
3
1 2 9
10 1 1
输出:
19
样例 3
输入:
1
7
4
输出:
7
样例解释(英文原文)
In the first example Demid can choose the following team as follows:
In the second example Demid can choose the following team as follows:
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |