Imagine you're a project manager juggling multiple exciting projects, each with their own milestones to complete! π―
You have n projects numbered from 0 to n - 1, and you're given an integer array milestones where each milestones[i] represents the number of milestones the i-th project has.
The Challenge: You want to maximize your productivity while following these strict rules:
- πΉ Consistency: Every week, you must finish exactly one milestone from one project
- πΉ Variety: You cannot work on the same project for two consecutive weeks
Your goal is to determine the maximum number of weeks you can work before being forced to stop due to these constraints. You might not be able to complete all milestones due to the alternating rule!
Input: An array of integers representing milestone counts for each project
Output: The maximum number of weeks you can work
Input & Output
Constraints
- n == milestones.length
- 1 β€ n β€ 105
- 1 β€ milestones[i] β€ 109
- The sum of all milestones can be very large (up to 1014)