Canadian Computing Olympiad: 2019 Day 2, Problem 2
Hannah is building a structure made of marshmallows and skewers for her chemistry class. The structure will contain
Hannah has
To ensure the stability of the structure, the following requirement must also be satisfied: if
Due to austerity measures imposed by the principal's office, skewers are scarce in Hannah's school. Find the minimum number of skewers necessary to satisfy all requirements.
Input Specification
The first line contains two space-separated integers
The next
For 5 of the 25 marks available,
For an additional 5 of the 25 marks available,
For an additional 5 of the 25 marks available, for all
Output Specification
Output a single integer, the minimum total number of skewers.
Sample Input 1
6 4
1 2
1 4
4 6
4 5
Output for Sample Input 1
6
Explanation for Output for Sample Input 1
In addition to those already required, there must be skewers between the pairs of marshmallows
Sample Input 2
7 6
2 3
2 6
2 7
1 3
1 4
1 5
Output for Sample Input 2
16
Comments