Can someone give solution to this? I tried but somehow unable to get correct answer
Meet Alex, a bright student who is dealing with an array challenge today. He has been given an array a1, a2, ..., aN of length N. The intriguing aspect of this challenge is that Alex can perform various operations on the array elements.
In a single operation, Alex is allowed to choose two indices l and r, where 1 ≤ l ≤ r ≤ n. He can then multiply all the elements in the subarray [al, al+1, ..., ar] by -1, effectively reversing their signs.
Being pressed for time as he is running late for school, Alex is seeking your assistance in determining the maximum possible sum of numbers in the array. Additionally, he is eager to find out the minimum number of operations required to achieve this maximum sum.
Input Format The first line contains an integer N, the length of the array.
The second line contains N space-separated integers a1, a2, ..., an, the array elements.
Constraints 1 ≤ N ≤ 2 * 10^5
-10^9 ≤ ai ≤ 10^9
Output Format Print two space-separated integers: the maximum possible sum of integers in the array and the minimum number of operations required to achieve this sum.
Sample TestCase 1 Input 4 -1 0 -2 -1 Output 4 1 Explanation
We should select:
l = 0
r = 3
After one operation,
Array [0, 3] = { 1, 0, 2, 1}
The sum of the array = 1+0+2+1 = 4
Time Limit(X): 0.50 sec(s) for each input. Memory Limit: 512 MB Source Limit: 100 KB
thanks you for the help