Skip to content

USACO 2020 December Contest Bronze Division - Do You Know Your ABCs?#

Problem link: here

Solution Author: Stefan Dascalescu

Problem Solution#

Sort the seven numbers, the first two are the first two numbers, then it comes down to some casework in order to decide which number is the third number (either the third or the fourth number from the original array).

Source codes#

The source codes in C++ and Python can be seen below.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    vector<int> v(7);
    for(int i = 0; i < 7; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[0] << " " << v[1] << " ";
    if(v[2] < v[1] + v[0])
        cout << v[2];
    else
        cout << v[3];
    return 0;
}
v = list(map(int, input().split()))
v.sort()
print(v[0], v[1], end=" ")
if v[2] < v[0] + v[1]:
    print(v[2])
else:
    print(v[3])