A11105 | Curriculum Vitae
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.
During all his career Hideo has produced $n$ games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.
More formally, you are given an array $s_{1},s_{2},...,s_{n}$ of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.
Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.
During all his career Hideo has produced $n$ games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.
More formally, you are given an array $s_{1},s_{2},...,s_{n}$ of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.
Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.
输入格式
The first line contains one integer number $n$ ( $1<=n<=100$ ).
The second line contains $n$ space-separated integer numbers $s_{1},s_{2},...,s_{n}$ ( $0<=s_{i}<=1$ ). $0$ corresponds to an unsuccessful game, $1$ — to a successful one.
The second line contains $n$ space-separated integer numbers $s_{1},s_{2},...,s_{n}$ ( $0<=s_{i}<=1$ ). $0$ corresponds to an unsuccessful game, $1$ — to a successful one.
输出格式
Print one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.
输入输出样例
输入 #1
4 1 1 0 1
输出 #1
3
输入 #2
6 0 1 0 0 1 0
输出 #2
4
输入 #3
1 0
输出 #3
1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted