A7941 | Animals
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse storing Ogudar-Olok, a magical but non-alcoholic drink) came home after a hard day. That day he had to drink 9875 boxes of the drink and, having come home, he went to bed at once.
DravDe dreamt about managing a successful farm. He dreamt that every day one animal came to him and asked him to let it settle there. However, DravDe, being unimaginably kind, could send the animal away and it went, rejected. There were exactly $n$ days in DravDe’s dream and the animal that came on the $i$ -th day, ate exactly $c_{i}$ tons of food daily starting from day $i$ . But if one day the animal could not get the food it needed, it got really sad. At the very beginning of the dream there were exactly $X$ tons of food on the farm.
DravDe woke up terrified...
When he retold the dream to you, he couldn’t remember how many animals were on the farm by the end of the $n$ -th day any more, but he did remember that nobody got sad (as it was a happy farm) and that there was the maximum possible amount of the animals. That’s the number he wants you to find out.
It should be noticed that the animals arrived in the morning and DravDe only started to feed them in the afternoon, so that if an animal willing to join them is rejected, it can’t eat any farm food. But if the animal does join the farm, it eats daily from that day to the $n$ -th.
DravDe dreamt about managing a successful farm. He dreamt that every day one animal came to him and asked him to let it settle there. However, DravDe, being unimaginably kind, could send the animal away and it went, rejected. There were exactly $n$ days in DravDe’s dream and the animal that came on the $i$ -th day, ate exactly $c_{i}$ tons of food daily starting from day $i$ . But if one day the animal could not get the food it needed, it got really sad. At the very beginning of the dream there were exactly $X$ tons of food on the farm.
DravDe woke up terrified...
When he retold the dream to you, he couldn’t remember how many animals were on the farm by the end of the $n$ -th day any more, but he did remember that nobody got sad (as it was a happy farm) and that there was the maximum possible amount of the animals. That’s the number he wants you to find out.
It should be noticed that the animals arrived in the morning and DravDe only started to feed them in the afternoon, so that if an animal willing to join them is rejected, it can’t eat any farm food. But if the animal does join the farm, it eats daily from that day to the $n$ -th.
输入格式
The first input line contains integers $n$ and $X$ ( $1<=n<=100,1<=X<=10^{4}$ ) — amount of days in DravDe’s dream and the total amount of food (in tons) that was there initially. The second line contains integers $c_{i}$ ( $1<=c_{i}<=300$ ). Numbers in the second line are divided by a space.
输出格式
Output the only number — the maximum possible amount of animals on the farm by the end of the $n$ -th day given that the food was enough for everybody.
输入输出样例
输入 #1
3 4 1 1 1
输出 #1
2
输入 #2
3 6 1 1 1
输出 #2
3
Note to the first example: DravDe leaves the second and the third animal on the farm. The second animal will eat one ton of food on the second day and one ton on the third day. The third animal will eat one ton of food on the third day.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted