Close
Topic list
SICK NINJA
HARD
40 mins
Dynamic Programming
Topics (Covered in this problem)
Problem solved
Skill meter
Dynamic Programming
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# SICK NINJA

Contributed by
Abhishek Gupta
Hard
0/120
Avg time to solve 40 mins
Success Rate 40 %
Share

## Problem Statement

#### Note: If there are multiple values of costs possible for maximum nutrition, you need to find the minimum one.

##### Example:
``````Suppose there are 3 fruits with costs 1, 2, 3 and nutrition  2, 2, 3 units respectively. Ninja has 3 units of money. Then, the ninja can take fruits with costs 1 and 2, having the maximum nutritional value of  4 units for a cost of 3 units.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````2
9 4
1 2
2 3
4 5
5 7
6 3
7 4
9 2
11 12
``````
##### Sample Output 1 :
``````12 8
0 0
``````
##### Explanation of sample input 1 :
``````For the first test case:-
The ninja can select the fruits at indices ( 0 - based ) 0, 1, and 3, which constitutes 12 units of nutrition and 8 units of cost.

For the second test case:-
The Ninja can not buy any of these fruits so he will have his nutrition as 0 and cost also 0 as well
``````
##### Sample Input 2 :
``````2
50 10
12 3
15 8
16 9
16 6
10 2
21 9
18 4
12 4
17 8
18 9
50 10
13 8
19 10
16 8
12 9
10 2
12 8
13 5
15 5
11 7
16 2
``````
##### Sample Output 2:
``````26 49
32 48
``````
Auto
Console