RealTaskWithTwins
TCC19 South America Final · 2019-06-10 · by misof
Problem Statement
There is a group of N >= 2 people. There are some individuals and some pairs of twins. If we write down the age of each individual and also the age of each pair of twins (but only once, not twice), the numbers we will get are all distinct integers between 1 and 200, inclusive.
You were shown a photograph.
There are N-1 people in the photograph because the N-th person was taking it.
For each person in the photograph you were told their age.
These are given to you in the
Given what you know, determine the following values:
- Amax = the largest possible age of a pair of twins
- Tmax = the largest possible number of pairs of twins
Return the
Notes
- It can be shown that Tmax is always positive and therefore Amax is always defined.
Constraints
- ages will contain between 1 and 50 elements, inclusive.
- Each element of ages will be between 1 and 200, inclusive.
- Each value will occur at most twice in ages.
{10, 20, 30, 10, 30}
Returns: {30, 3 }
It is possible that there are three pairs of twins. This happens precisely when the person taking the photograph is 20 years old, and thus the twin of one of the people in the photograph. Regardless of the age of the missing person, the oldest pair of twins are the two 30-year-olds in the photograph.
{47}
Returns: {47, 1 }
The person taking the photograph may or may not be the twin of the person in it.
{10, 50, 47, 20, 24, 43, 13}
Returns: {50, 1 }
{10, 17, 109, 17, 23, 109, 10, 23}
Returns: {109, 4 }
{10, 17, 109, 17, 23, 108, 10, 23}
Returns: {109, 4 }
Submissions are judged against all 131 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RealTaskWithTwins with a public method vector<int> solve(vector<int> ages) · 131 test cases · 2 s / 256 MB per case