

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
消毒液の入ったボトルがあり、その消毒液によってちょうど 本の手を消毒することができます。
人の宇宙人が順に手の消毒を行いに来ます。
人目 () の宇宙人は 本の手を持っており、それぞれ自身のすべての手を 回ずつ消毒したいと考えています。
何人目の宇宙人までがすべての手を消毒できるか求めてください。
ただし、ある宇宙人が消毒を始める時点で、自身のすべての手を消毒する分の消毒液が残っていなかったとしても、その宇宙人はその消毒液を使い切ってしまうものとします。
制約
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
何人目の宇宙人までが自身のすべての手を消毒できるか出力せよ。
入力例 1Copy
5 10 2 3 2 5 3
出力例 1Copy
3
次の手順で宇宙人は自身の手を消毒します。
- 人目の宇宙人は自身の 本の手を消毒します。残りの消毒液によって、 本の手を消毒できます。
- 人目の宇宙人は自身の 本の手を消毒します。残りの消毒液によって、 本の手を消毒できます。
- 人目の宇宙人は自身の 本の手を消毒します。残りの消毒液によって、 本の手を消毒できます。
- 人目の宇宙人は 本の手を持っていますが、消毒液は 本分しかないため消毒液を使い切り、かつ自身のすべての手を消毒できません。
よって、 人目の宇宙人までが自身のすべての手を消毒できるため、 を出力します。
入力例 2Copy
5 10 2 3 2 3 5
出力例 2Copy
4
入力例 3Copy
1 5 1
出力例 3Copy
1
すべての宇宙人が自身の手を消毒することができます。
Score : points
Problem Statement
There is a bottle of disinfectant that can disinfect exactly hands.
aliens come one by one to disinfect their hands.
The -th alien () has hands and wants to disinfect all of their hands once.
Determine how many aliens can disinfect all of their hands.
Here, even if there is not enough disinfectant left for an alien to disinfect all of their hands when they start, they will use up the remaining disinfectant.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number of aliens who can disinfect all of their hands.
Sample Input 1Copy
5 10 2 3 2 5 3
Sample Output 1Copy
3
The aliens disinfect their hands in the following steps:
- The first alien disinfects their two hands. The remaining disinfectant can disinfect hands.
- The second alien disinfects their three hands. The remaining disinfectant can disinfect hands.
- The third alien disinfects their two hands. The remaining disinfectant can disinfect hands.
- The fourth alien has five hands, but there is only enough disinfectant for three hands, so they use up the disinfectant without disinfecting all of their hands.
Thus, the first three aliens can disinfect all of their hands, so print .
Sample Input 2Copy
5 10 2 3 2 3 5
Sample Output 2Copy
4
Sample Input 3Copy
1 5 1
Sample Output 3Copy
1
All aliens can disinfect their hands.