Company: Barclays
Difficulty: medium
Project Work Schedule Language: CPP | GCC Version: 5.5.0 An employee in an organization has begun working on N projects (numbered 0 to N-1). Each week he/she can work on a single module of one of the projects. The modules that are chosen to work on in two successive weeks should come from different projects. A project can have at most C modules. The modules of the projects are such that a module is completed in a week. Write an algorithm to determine the number of weeks the employee can work on projects following the above mentioned rules. Input Format The first line of the input consists of an integer num , representing the number of projects (N). The next line consists of N space-separated integers projC[0], projC[1], ..., projC[N-1] , representing the number of modules of the projects. Output Format Print an integer representing the maximum number of weeks the employee can work on the projects. Constraints 1 ≤ num ≤ 10 5 1 ≤ projC ≤ 10 5 1 ≤ projC[i] ≤ 10 5 0 ≤ i Example Input: 3 1