You are viewing a single comment's thread. Return to all comments →
long[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), arrTemp => Convert.ToInt64(arrTemp)) ; Array.Sort(arr); long min = (arr[0]+arr[1]+arr[2]+arr[3]); long max = (arr[1]+arr[2]+arr[3]+arr[4]); Console.WriteLine(min + " " + max);
why not just sort it and add the first 4 then last 4? the problem stated it's always an array of 5
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
long[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), arrTemp => Convert.ToInt64(arrTemp)) ; Array.Sort(arr);
long min = (arr[0]+arr[1]+arr[2]+arr[3]); long max = (arr[1]+arr[2]+arr[3]+arr[4]); Console.WriteLine(min + " " + max);