USACO Bronze 2020 December - Do You Know Your ABCs?

Authors: Sathvik Chundru, Jeffrey Meng


Official Analysis (C++)

Video Solution

By Jeffrey Meng

Video Solution Code

Python

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}")

C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int nums[7];
for (int i = 0; i < 7; i++) { cin >> nums[i]; }
sort(nums, nums + 7);
int a = nums[0], b = nums[1];
int c = nums[6] - a - b;
cout << a << ' ' << b << ' ' << c << '\n';
}

Java

import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int nums[] = new int[7];
for (int i = 0; i < 7; i++) { nums[i] = sc.nextInt(); }
Arrays.sort(nums);
int a = nums[0], b = nums[1];
int c = nums[6] - a - b;
System.out.println(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!