Question
World of Lovecraft is the most popular MMORPG game. Jojo is currently fighting the last boss on the dungeon. After several minutes, Jojo killed the
World of Lovecraft is the most popular MMORPG game. Jojo is currently fighting the
last boss on the dungeon. After several minutes, Jojo killed the boss. Jojo was hoping
for a rare weapon dropped by the boss. But all the items dropped are just another junks
to sell. The inventory mechanics of World of Lovecraft is limited by weight. Currently,
Jojos backpack can carry K total weight. The boss dropped N items and each item has
its own sell value and its own weight. Lets say Vi
is the sell value of i-th item and Wi
is
the weight of i-th item.
Of course Jojo wants to take all the items (if he can take it all) and sell it immediately.
But again, the inventory is limited by weight. Jojo has to go out from the dungeon to
sell. But once he is out of the dungeon, he cant re-enter the dungeon and thus the items
that left there will be gone. As a good friend of Jojo, help Jojo to find the maximum sell
value Jojo can carry with his limited weight backpack.
Format Input
There are T testcases. Every testcase consists of a line of a line of two integers N and K
as described above. Followed by N lines of Vi and Wi as described above.
Format Output
Output T testcases with format Case #X: , where X indicates the testcase number
and then followed by an integer indicates the maximum sell value Jojo can carry with his
limited weight backpack.
Constraints
1 T 10
1 N 20
1 K 10^9
1 Vi
, Wi 10^9
Sample Input (standard input)
3
5 30
3 10
2 15
4 12
5 6
7 20
5 100
3 10
2 15
4 12
5 6
7 20
5 5
3 10
2 15
4 12
5 6
7 20
Sample Output (standard output)
Case #1: 12
Case #2: 21
Case #3: 0
Note : Use C Language , Dont Use Stdlib as you can, stdio.h and string.h only
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started