atcoder#ARC106E. [ARC106E] Medals

[ARC106E] Medals

Score : 700700 points

Problem Statement

You run a shop employing NN employees. Each employee comes to work in a fixed cycle. More specifically, starting today, the ii-th employee repeats the following: working for AiA_i consecutive days and then taking AiA_i consecutive days off.

Every day starting today, you will come to work and give a medal to an employee of your choice who comes to work that day. (If no employee comes to work, you will do nothing that day.)

At least how many days does it takes to give every employee KK or more medals?

Constraints

  • All values in input are integers.
  • 1N181 \le N \le 18
  • 1K1051 \le K \le 10^5
  • 1Ai1051 \le A_i \le 10^5

Input

Input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \cdots ANA_N

Output

Print the answer.

3 3
1 2 3
10

For example, you can choose to give them medals as follows:

  • Give a medal to the 11-st employee on the 11-st, 55-th, and 99-th days.
  • Give a medal to the 22-nd employee on the 22-nd, 66-th, and 1010-th days.
  • Give a medal to the 33-rd employee on the 33-rd, 77-th, and 88-th days.

Since no employee comes to work on the 44-th day, this is one of the ways to achieve the objective in the minimum number of days.

10 10
1 1 1 1 1 1 1 1 1 1
199
2 5
1234 5678
10