NC222440. [USACOFeb2021S]YearoftheCow
描述
输入描述
The first line of input contains N and K. The next N lines contain N distinct integers in the range 1…109, indicating how many years ago each of Bessie's N ancestors lived.
输出描述
Print the minimum number of years it will take Bessie to visit all her ancestors and return to the present year.
示例1
输入:
5 3 101 85 100 46 95
输出:
36
说明:
One way for Bessie to visit all her ancestors and return in 36 years is as follows:
Enter the portal in the present day and travel 48 years into the past.
Wait 12 years, then enter the portal 36 years in the past and travel 108 years into the past.
Wait 24 years, then enter the portal 84 years in the past and travel back to the present year.
Problem credits: Brian Dean and David Yang
Problem credits: Brian Dean and David Yang