Covid Vaccination Distribution Problem

As the Government ramps up vaccination drives to combat the second wave of Covid-19, you are tasked with helping plan an effective vaccination schedule. Your goal is to maximize the number of vaccines administered on a particular day, while adhering to certain rules.

Explanation:

Given two positive integers, n and maxVaccines, indicating the number of days for the vaccination drive and the total available vaccines respectively, you must find the number of vaccines distributed each day. Additionally, a specific day, dayNumber, is provided, and you need to maximize the number of vaccines on this day.

Rules:

  1. A positive number of vaccines must be administered each day.
  2. The difference in the number of vaccines between any two consecutive days cannot exceed 1.
  3. The sum of vaccines distributed must not exceed maxVaccines.
  4. The vaccines administered on dayNumber must be maximized.

Input:

The first line of input contains an integer 'T', the number of test cases. Each test case consists of one line with three integers: n, dayNumber, and maxVaccines.

Output:

For each test case, output a single integer representing the maximum number of vaccines administered on the dayNumber day. Each result should be on a new line.

Example:

Input:
T = 2
n = 3, dayNumber = 1, maxVaccines = 6
n = 4, dayNumber = 2, maxVaccines = 10
Output:
3
4

Constraints:

  • 1 <= T <= 50
  • 1 <= n <= maxVaccines <= 10^9
  • 0 <= dayNumber < n
  • Time Limit: 1 sec

Note:

No need to print output; just implement the function logic as needed.

AnswerBot
4mo

Maximize the number of vaccines administered on a specific day while adhering to certain rules.

  • Given n days, maxVaccines available, and a specific dayNumber, distribute vaccines to maximize on dayNumb...read more

Help your peers!
Select
Add answer anonymously...

Ernst & Young React Developer interview questions & answers

A React Developer was asked Q. Can you explain hoisting in JavaScript?
A React Developer was asked Q. How can we structure the top-level directories in Redux?
A React Developer was asked Q. What is the Combine Reducer in Redux?

Popular interview questions of React Developer

A React Developer was asked Q1. Can you explain hoisting in JavaScript?
A React Developer was asked Q2. How can we structure the top-level directories in Redux?
A React Developer was asked Q3. What is the Combine Reducer in Redux?
Ernst & Young React Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits