No.3713 Seabed Exploration
タグ : / 解いたユーザー数 22
作問者 :
へきぼこ 競プロのすがた
/ テスター :
UT0911
Problem Statement
You are investigating ruins on the seabed. The ruins contain $N$ treasure chests, which attack you when you try to take them home.
Treasure chest $i$ has weight $X_i$ and attack power $Y_i$. You can carry a weight of at most $A$ and can withstand attacks of at most $B$.
The total weight must be at most $A$. The total attack power must also be at most $B$.
Find the maximum number of treasure chests you can take home.
The attack power of a treasure chest may be very high.
Input
$N\ A\ B$ $X_1\ Y_1$ $X_2\ Y_2$ : $X_N\ Y_N$
Constraints
$1 \leq N \leq 100$
$1 \leq A \leq 100$
$1 \leq B \leq 10^9$
$1 \leq X_i \leq 100$
$1 \leq Y_i \leq 10^9$
All input values are integers.
Output
Output the maximum number of treasure chests you can take home.
Print a newline at the end.
Sample
Sample 1
Input
3 10 100 9 30 4 50 5 30
Output
2
If you choose the $2$ nd and $3$ rd treasure chests, the total weight is $4+5=9$ and the total attack power is $50+30=80$, so you can safely take them home.
Sample 2
Input
5 20 150 5 10 4 20 8 40 2 90 7 30
Output
4
You should choose chests number $1,2,4,5$.
Sample 3
Input
3 50 100000000 10 1000000 40 1000000 20 100000000
Output
2
The attack power of a treasure chest may be very high.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。