Recycling Pens Problem Statement
Imagine you have a certain number of empty pens, and some money in your pocket. For each pen, you can choose to either recycle it for a reward or buy a refill to make it usable again. Your goal is to find the maximum number of usable pens you can achieve given the constraints.
Example:
Input:
N = 5, R = 10, K = 2, C = 3
Output:
4
Explanation:
Recycle one pen to get 2 rupees, resulting in 12 rupees. With this, buy 4 refills and combine with 4 pens to make them usable, achieving the maximum of 4 usable pens.
Constraints:
1 ≤ T ≤ 10^5
1 ≤ N ≤ 10^9
0 ≤ R ≤ 10^9
1 ≤ K ≤ 10^9
1 ≤ C ≤ 10^9
- Time limit: 1 sec
Input:
The first line contains integer 'T', the number of test cases. Each test case consists of four space-separated integers: 'N', 'R', 'K', and 'C'.
Output:
For each test case, output the maximum number of usable pens.
Note:
No need to print anything. Just implement the solution function and return the result.

AnswerBot
4mo
Given empty pens, money, and costs, maximize usable pens by recycling and buying refills.
Calculate total money after recycling pens
Determine number of refills that can be bought with the money
Combine ...read more
Help your peers!
Add answer anonymously...
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

