A7920 | Company Income Growth
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Petya works as a PR manager for a successful Berland company BerSoft. He needs to prepare a presentation on the company income growth since $2001$ (the year of its founding) till now. Petya knows that in $2001$ the company income amounted to $a_{1}$ billion bourles, in $2002$ — to $a_{2}$ billion, ..., and in the current $(2000+n)$ -th year — $a_{n}$ billion bourles. On the base of the information Petya decided to show in his presentation the linear progress history which is in his opinion perfect. According to a graph Petya has already made, in the first year BerSoft company income must amount to $1$ billion bourles, in the second year — $2$ billion bourles etc., each following year the income increases by $1$ billion bourles. Unfortunately, the real numbers are different from the perfect ones. Among the numbers $a_{i}$ can even occur negative ones that are a sign of the company’s losses in some years. That is why Petya wants to ignore some data, in other words, cross some numbers $a_{i}$ from the sequence and leave only some subsequence that has perfect growth.
Thus Petya has to choose a sequence of years $y_{1}$ , $y_{2}$ , ..., $y_{k}$ ,so that in the year $y_{1}$ the company income amounted to $1$ billion bourles, in the year $y_{2}$ — $2$ billion bourles etc., in accordance with the perfect growth dynamics. Help him to choose the longest such sequence.
Thus Petya has to choose a sequence of years $y_{1}$ , $y_{2}$ , ..., $y_{k}$ ,so that in the year $y_{1}$ the company income amounted to $1$ billion bourles, in the year $y_{2}$ — $2$ billion bourles etc., in accordance with the perfect growth dynamics. Help him to choose the longest such sequence.
输入格式
The first line contains an integer $n$ ( $1<=n<=100$ ). The next line contains $n$ integers $a_{i}$ ( $-100<=a_{i}<=100$ ). The number $a_{i}$ determines the income of BerSoft company in the $(2000+i)$ -th year. The numbers in the line are separated by spaces.
输出格式
Output $k$ — the maximum possible length of a perfect sequence. In the next line output the sequence of years $y_{1}$ , $y_{2}$ , ..., $y_{k}$ . Separate the numbers by spaces. If the answer is not unique, output any. If no solution exist, output one number $0$ .
输入输出样例
输入 #1
10 -2 1 1 3 2 3 4 -10 -2 5
输出 #1
5 2002 2005 2006 2007 2010
输入 #2
3 -1 -2 -3
输出 #2
0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted