Nellex and GraVITas
All submissions for this problem are available.
Nellex is coming to VIT this gravitas to make loads of money by wining various coding event.
Being the best in this business, it is known that he'll win each and every event that he participates in.
However he'll be staying in here for only some amount of hours. Given the amount of cash prize associated with each and every event and the number of hours to be spent in each of these event, you're supposed to print the maximum cash prize that he can take back with him, taking into consideration that he'll only work for a fixed amount of hours.
The first line contains an integer t, denoting the number of test cases.
This is follwed by two space seperated integers n and m, where n denotes the number of hours that nellex can spend and m denotes the number of events in GraVITas.
Then m lines follow, each containing two space separated integers denoting the number of hours that is to be spent in the event and the cash prize associated with it.
On a single line output the maximum cash prize he can take back with him for each test case.
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ T ≤ 50
- 0 ≤ N ≤ 500
- 1 ≤ M ≤ 100
- 0 ≤ Cash Prize (in thousands) ≤ 10
Input: 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 Output: 26 32
In the first test case the most optimal way to spend his time i.e 50hrs in graVITas would be by going to the event (18 9), (16 9), (15 8), wherein he'll be making Rs. 26 (thousand) money and will be spending (18+16+15) = 49 hrs < 50 hrs.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.