Problem:
Farmer John's cows have been holding a daily online gathering on the "mooZ" video meeting platform. For fun, they have invented a simple number game to play during the meeting to keep themselves entertained.
Elsie has three positive integers , , and (). These integers are supposed to be secret, so she will not directly reveal them to her sister Bessie. Instead, she gives Bessie seven (not necessarily distinct) integers in the range , claiming that they are , , , , , , and in some order.
Given a list of these seven numbers, please help Bessie determine , , and . It can be shown that the answer is unique.
The only line of input consists of seven space-separated integers.
Print , , and separated by spaces.
My Code:
import java.util.*;
public class BaekJoon_20650 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] input = new int[7];
for (int i = 0; i < 7; i++) {
input[i] = scanner.nextInt();
}
scanner.close();
Arrays.sort(input);
int a = input[0];
int b = input[1];
int max = input[6];
int c = max - a - b;
System.out.print(a + " " + b + " " + c);
}
}
Input
2 2 11 4 9 7 9
Output
2 2 7