atcoder#ARC106E. [ARC106E] Medals
[ARC106E] Medals
Score : points
Problem Statement
You run a shop employing employees. Each employee comes to work in a fixed cycle. More specifically, starting today, the -th employee repeats the following: working for consecutive days and then taking 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 or more medals?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
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 -st employee on the -st, -th, and -th days.
- Give a medal to the -nd employee on the -nd, -th, and -th days.
- Give a medal to the -rd employee on the -rd, -th, and -th days.
Since no employee comes to work on the -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