Derek USACO

Описание к видео Derek USACO

USACO 2020 December Contest, Bronze
Problem 1. Do You Know Your ABCs?

A
B
C
A + B
B + C
A + C
A + B + C



Observation 1 : A == B and B == C and C ==A, they are all the same

Observation 2 : A + B + C must be the largest

Therefore, it is ideal to store all the seven number in an array

array = [A + B + C, A, B, C, A + B, A + C, B + C]
obviously, the question does not say the data is sorted…therefore it is very suspicious that we want to sort array first

that leads to using sort(array, array + N)

and then, the largest number is array[N - 1] → easily get A + B + C → sum of three numbers

it is guarantee that the smallest data in array is array[0] → A

Now, the question is solving two unknowns with one is solved and sum of the three is solved.

A +B + C = T
A = K
B + C = ?

yes, B is the one next to A therefore B = array[1]
now, we know A, B, A + B + C , and then C is (A + B + C) - A - B = A + B + C - A - B = C
C = A + B + C - array[0] - array[1]

Комментарии

Информация по комментариям в разработке