Company: Barclays
Difficulty: medium
Project Work Weeks A team member has started work on N ongoing projects (numbered 0 to N-1). During any single week, this person can complete exactly one module belonging to one of the projects. Which project to draw a module from each week is decided based on how many modules remain across the different projects, and no project may contribute more than C modules in total. Every individual module, regardless of which project it belongs to, takes exactly one week to finish. Given this setup, work out the total number of weeks the team member ends up spending across all the projects under the rules above. Input Format The first line of input holds an integer num , the number of projects (N). The following line holds N space-separated integers, projC 0 , projC 1 , ..., projC N-1 , giving the module count for each project. Output Format Print a single integer giving the largest possible number of weeks the team member can spend working across the projects. Constraints 1 ≤ num ≤ 10 4 1 ≤ pr