All submissions for this problem are available.
An exam consists of N questions. The marks of the N questions are m1, m2, m3, .. mN respectively.
Jam is giving the exam and he wants to maximise his number of marks.
However he takes some time to solve each question. The time taken by him to solve the questions are t1, t2, t3, .. tN respectively.
The exams lasts for a total of time T.
But Jam's teacher is very smart and she knows that Jam will find out a way to get maximum marks. So, to confuse Jam, she also puts up a bonus offer for him -
The offer is that Jam can select a question for which he can double the marks awarded for that question.
Now, Jam is indeed confused. Help him find out the maximum number of marks he can gain.
The first line contains a single integer N, that represents the number of questions.
Second line contains a single integer T, the total time for which the exam takes place.
Third line contains N space-separated integers
m1, m2, m3, ... mN, where mi represents marks assigned to the ith question.
Fourth line contains N space-separated integers
t1, t2, t3, ... tN, where ti represents time taken to solve the ith question.
Output a single integer, that is the maximum number of marks Jam can achieve.
Input: 3 10 1 2 3 4 3 4 Output: 8
|Tags||dynamic-programming, knapsack, ncc2014, wittyceaser|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, GO, HASK, SCALA, PERL, CAML, ASM, PERL6, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.