Company: Tech Mahindra_6oct
Difficulty: medium
Maximize Sales Days Problem Description A travelling salesperson works in N towns. Each day the salesperson sells products in one of the towns. The towns that are chosen on any two successive days should be different, and a town i can be chosen at most countTown[i] times. Write an algorithm to determine the maximum number of days the salesperson can sell in the given towns following these rules. Your solution should be implemented in the following function signature: int maxDaysToWork(vector<int> countTown) { int answer; // Write your code here return answer; } Input Format The first line of the input consists of an integer num , representing the number of towns ( N ). The next line consists of N space-separated integers countTown[0], countTown[1], ..., countTown[N-1] , representing the number of times each town can be chosen. Output Format Print an integer representing the maximum number of days during which the salesman can work. Examples Example 1: Input: 3 7 2 3 Output: 11 Ex