Company: Infoedge_26april
Difficulty: medium
Delicious Food Cooking Problem Description You're assisting your mother in cooking a delicious meal. However, the gas stove only has 2 burners, limiting you to cook a maximum of 2 items simultaneously. You're provided with an integer array arr of length n , where arr[i] represents the time required to cook the i th dish. Your objective is to determine the minimum time needed to prepare all the dishes. Input Format The first line contains an integer n , denoting the number of dishes. The following n lines contain integers, denoting the time required to cook the dishes (in sec). Output Format Print the minimum time required to prepare all the dishes. Examples Example 1: Input: 5 8 3 7 2 5 Output: 13 Explanation: At time t = 0, we place the 5th dish on burner 1 and 2nd dish on burner 2. At time t = 3, the 2nd dish is cooked on burner 2. So we place the 4th dish to cook. At time t = 5, the 5th and the 4th dish are cooked. So we place the 1st dish on burner 1 and the 3rd dish on burner 2. A