package solution;
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the miniMaxSum function below.
static void miniMaxSum(int[] arr) {
int suma = 0;
int num = 0;
for(int i = 0; i < arr.length; i++){
num = arr[i];
suma = suma + num;
}
Arrays.sort(arr);
System.out.println((suma-arr[arr.length-1]) + " " + (suma-arr[0]));
}
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int[] arr = new int[5];
String[] arrItems = scanner.nextLine().split(" ");
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
for (int i = 0; i < 5; i++) {
int arrItem = Integer.parseInt(arrItems[i]);
arr[i] = arrItem;
}
miniMaxSum(arr);
scanner.close();
}
}
That is the complete code of the exercise already with my solution in the.
But if these values are set: 256741038 623958417 467905213 714532089 938071625
.
In the last sum 2063136757 + 938071625 me da = -1293758914
!!!! I do not understand why, I already debug it and everything goes well but adding those amounts gives me that result !!!
The weird thing is that with the minimum value 256741038
, when you rest -1293758914 - 256741038
, if you give me the correct value of the exercise that is 2063136757
. But with the maximum value it gives me -1550499952
.
Expected outputs are assumed to be 2063136757 2744467344