Official Analysis (C++)

Video Solution

By Jeffrey Meng

Video Solution Code

Explanation

Notice that the two smallest values in the sorted list will be AA and BB, and the largest value will always equal to A+B+CA + B + C. By subtracting AA and BB from A+B+CA + B + C, we obtain the value of CC.

Implementation

Time Complexity: O(1)\mathcal{O}(1)

nums = sorted([int(x) for x in input().split()])
a, b = nums[0], nums[1]
c = nums[6] - a - b
print(f"{a} {b} {c}")

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!