Fill The Bags
All submissions for this problem are available.
Delta is the Coding Club of NIT Trichy. Recently they planned to go for a trip. Two girls Aarti and Bhavya got stuck while packing. Aarti had a bag of weight holding capacity w1 and bhavya had a bag of weight holding capacity of w2 .They had n1 objects with weight 1 unit each and n2 objects with weight 2 units each.
Your task is simple. Help them find the maximum weight of objects that can fit in these 2 bags.
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains four integers w1, w2, n1, n2
- For each test case, output a single line containing the answer.
- 1 ≤ T ≤ 10^5
- 1 ≤ w1, w2, n1, n2 ≤ 10^9
Input: 2 2 2 1 1 3 2 3 2 Output: 3 5
|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, CLOJ, FS|
Fetching successful submissions