Help Sunny Sir!
All submissions for this problem are available.
The End Terminal Exams are only a few weeks away and Sunny sir is quite tensed because a major portion of Physics has still been left to cover up!! He still has N units to finish. Since the exam pattern is always fixed in IPU, each unit has different priorities associated with it. For example, he knows that a question on Maxwell Equations or Skin Depth from Unit 1, Davison Germer Experiment from Modern Physics and Derivations from Relativity are sure shot questions. Let's say Array Ai denotes the importance of ith unit. Each Unit Ai requires an investment of Ti hours of time. There are only at most W hours sir can devote to his class because now he is married so he got other responsibilities towards his family! Now he wants to decide how to make his students score well by carefully choosing which units to teach such as to maximize the important topics coverage in at most W hours of time. Can you help Sunny Sir to find out the sum of all the important units he can cover? :)
See Sample Input/Output for further details/clarification.
- The first line of input contains an integer T followed two integers in the next line N and W denoting the number of units left to cover up and number of hours sir can devote respectively.The second line contains N space-separated integers A1, A2, ..., AN denoting the importance/weightage of the A[i]th unit.
The third and the last line contains N space-separated integers T1, T2, ..., TN denoting the amount of hours required to complete ith unit.
- For each test case, output a single line containing the sum of all the important units he can cover in at most given time.
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ N ≤ 100
- 1 ≤ A[i] ≤ 105
- 1 ≤ T[i] ≤ 105
Input: 1 5 15 3 6 2 1 9 5 3 6 2 9 Output: 16
Example case 1. Out of all the optimal possible combinations, the most important topics that can be covered with maximum weightage are 1st, 3rd and 5th topic (i.e A,A & A ) by spending 9+3+2 hours (i.e T,T & T) which is less than equal to W(i.e 15)
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, 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, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.