🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"DIWALI1","problem_name":"Maximum Light Up","problemComponents":{"constraints":"- $1 \\leq T \\leq 10^5$\n- $1 \\leq P, a, b, c, x, y \\leq 10^9$\n","constraintsState":true,"subtasks":"","subtasksState":true,"inputFormat":"- First line of input will contain $T$, the number of test cases. Then the test cases follow.\n- Each test case contains of a single line of input, six integers $P$, $a$, $b$, $c$, $x$ and $y$.\n","inputFormatState":true,"outputFormat":"For each test case, output in a single line the maximum total of Anars and Chakris Chef can light up.\n","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"3\n100 5 5 10 4 8\n16 2 2 2 1 1\n55 1 2 3 4 5","output":"4\n4\n9","explanation":"**Test case $1$:**\n- Chef will buy $16$ Fuljhari\u0027s and $4$ Anar\u0027s which in total costs him $16 \\cdot 5 + 4 \\cdot 5 = 100$ rupees. \n- Next, he uses $16$ Fuljhari\u0027s to light $\\frac{16}{4} = 4$ Anar\u0027s. \n- Since all the Fuljhari\u0027s are over, he can\u0027t light up any Chakri\u0027s.\n- So in total, he is able to light up $4 + 0 = 4$ Anar\u0027s and Chakri\u0027s.\n- There is no other allocation giving a better answer than this.\n\n\n**Test case $2$:**\n- Chef will buy $4$ Fuljhari\u0027s, $2$ Anar\u0027s and $2$ Chakri\u0027s which in total costs him $4 \\cdot 2 + 2 \\cdot 2 + 2 \\cdot 2 = 16$ rupees. \n- Next, he uses $2$ Fuljhari\u0027s to light $\\frac{2}{1} = 2$ Anar\u0027s. \n- Next, he uses $2$ Fuljhari\u0027s to light $\\frac{2}{1} = 2$ Chakri\u0027s. \n- So in total, he is able to light up $2 + 2 = 4$ Anar\u0027s and Chakri\u0027s.\n- The other possible allocation could be buying $4$ Fuljhari\u0027s, $3$ Anar\u0027s, and $1$ Chakri.","isDeleted":false}}},"video_editorial_url":"https://youtu.be/U4KYH1I0vvg","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"suryaprak_adm","problem_tester":"","date_added":"23-09-2021","tags":{"0":"greedy","1":"simple","2":"start13","3":"suryaprak_adm"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/DIWALI1","time":{"view_start_date":1632663002,"submit_start_date":1632663002,"visible_start_date":1632663002,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=DIWALI1","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
Chef has allocated himself a budget of $P$ rupees to buy Diwali crackers. There are only $3$ types of crackers available in the market and each type of cracker can be bought any number of times.

1. Fuljhari, where each costs $a$ rupees
2. Anar, where each costs $b$ rupees
3. Chakri, where each costs $c$ rupees

The crackers have the following interesting properties:-
- A Fuljhari can be lit on its own 
- To light an Anar, you will need $x$ Fuljharis
- To light a Chakri, you will need $y$ Fuljharis

What's the maximum total of Anars and Chakris that Chef can light up with his given budget.
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>