103170: [Atcoder]ABC317 A - Potions

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:7 Solved:0

Description

Score : $100$ points

Problem Statement

Naohiro has a monster. The monster's current health is $H$.
He also has $N$ kinds of potions, numbered from $1$ to $N$ in ascending order of effectiveness.
If you give the monster potion $n$, its health will increase by $P_n$. Here, $P_1 \lt P_2 \lt \dots \lt P_N$.

He wants to increase the monster's health to $X$ or above by giving it one of the potions.
Print the number of the least effective potion that can achieve the purpose. (The constraints guarantee that such a potion exists.)

Constraints

  • $2 \leq N \leq 100$
  • $1 \leq H \lt X \leq 999$
  • $1 \leq P_1 \lt P_2 \lt \dots \lt P_N = 999$
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

$N$ $H$ $X$
$P_1$ $P_2$ $\dots$ $P_N$

Output

Print the number of the least effective potion that can achieve the purpose.


Sample Input 1

3 100 200
50 200 999

Sample Output 1

2

Below is the change in the monster's health when one of the potions is given to the monster.

  • If potion $1$ is given, the monster's health becomes $100 + 50 = 150$.
  • If potion $2$ is given, the monster's health becomes $100 + 200 = 300$.
  • If potion $3$ is given, the monster's health becomes $100 + 999 = 1099$.

The potions that increase the monster's health to at least $X = 200$ are potions $2$ and $3$. The answer is the least effective of them, which is potion $2$.


Sample Input 2

2 10 21
10 999

Sample Output 2

2

Sample Input 3

10 500 999
38 420 490 585 613 614 760 926 945 999

Sample Output 3

4

Output

分数:100分

问题描述

Naohiro有一个怪物。怪物当前的生命值为$H$。

他还拥有$N$种药水,按效果升序编号,从1到$N$。

如果你给怪物喝第$n$种药水,它的生命值将增加$P_n$。这里,$P_1 \lt P_2 \lt \dots \lt P_N$。

他想通过给怪物喝一种药水将怪物的生命值提高到$X$或以上。

打印可以达到目的的最不有效的药水编号。(约束条件保证了存在这样的药水)。

约束条件

  • $2 \leq N \leq 100$
  • $1 \leq H \lt X \leq 999$
  • $1 \leq P_1 \lt P_2 \lt \dots \lt P_N = 999$
  • 所有的输入值都是整数。

输入

输入从标准输入按以下格式给出:

$N$ $H$ $X$
$P_1$ $P_2$ $\dots$ $P_N$

输出

打印可以达到目的的最不有效的药水编号。


样例输入1

3 100 200
50 200 999

样例输出1

2

下面是给怪物喝药水时怪物的生命值的变化。

  • 如果给怪物喝第$1$种药水,怪物的生命值变为$100 + 50 = 150$。
  • 如果给怪物喝第$2$种药水,怪物的生命值变为$100 + 200 = 300$。
  • 如果给怪物喝第$3$种药水,怪物的生命值变为$100 + 999 = 1099$。

能将怪物的生命值提高到至少$X = 200$的药水是第$2$种和第$3$种药水。 答案是最不有效的药水,即第$2$种药水。


样例输入2

2 10 21
10 999

样例输出2

2

样例输入3

10 500 999
38 420 490 585 613 614 760 926 945 999

样例输出3

4

HINT

至少增加多少实力才能达到x?输出编号?

加入题单

算法标签: