Pass the semester
Submissions: 1944   Accuracy:


  Difficulty: Medium   Marks: 4

Satish wants to prepare for tommorow's exam . He knows the distribution of marks for the subject along with time to learn the concepts.
You are given remaining time for the exam along with marks for each topic and passing marks for the subject.
Find the max marks Satish can attain by studing max no of topic in max no hours not excedding (p) .


The first line of input contains the number of testcases t.
The first line of each testcase contains the no of topics(n) , time remaining for exam(h) in hour and passing marks(p).
Each 'n' lines contain u(time to learn topic) and v(weightage of topic in exam) .


For each test case print "YES" along with time taken or "NO".  







Sample Input 0
5 40 21 
12 10 
16 10 
20 10 
24 10 
8 3 

Sample Output 0 
YES 36

Explaination :

Marks needed to pass the subject  10 +10 + 3 = 23

Time taken to achieve the 23 marks : 12 + 6 + 8 =36

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: chunky_2808
Author: Chunky_2808

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.