![](https://static.ambitionbox.com/alpha/community/assets/dots.png)
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.
![](https://static.ambitionbox.com/alpha/community/assets/no-posts.png)
Be the first one to answer
Add answer anonymously...
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app