题目描述
Problem Description
E869120 went to a store called AtCoder Rotating Sushi.
There are $ N $ sushi at this store, each labeled with numbers $1,\ 2,\ 3,\ \cdots,\ N$. Sushi $ i $ can only be taken at times $ a_i+kT $ seconds after he arrives ($ k $ is a non-negative integer).
He wants to eat the sushi in the order of sushi $ 1 $ → sushi $ 2 $ → … → sushi $ N $. However, he is greedy and will eat a sushi as soon as he takes it. Determine the minimum number of seconds from his arrival until he finishes eating all $ N $ sushi. Time to take or eat sushi can be ignored, and he can take sushi that arrives at $ 0 $ seconds after his arrival.
Input Format
Input is given from the standard input in the following format:
$ N $ $ T $ $ a_1 $ $ a_2 $ $ a_3 $ ... $ a_N $
Output Format
Output the minimum number of seconds required to finish eating all the sushi in the specified order.
Sample Input and Output
Sample Input #1
1 6
4
Sample Output #1
4
Sample Input #2
3 10
3 7 2
Sample Output #2
12
Sample Input #3
6 15
8 6 9 1 2 0
Sample Output #3
45
Notes/Hints
Constraints
- $ N $ is an integer between $ 1 $ and $ 100 $ inclusive.
- $ T $ is an integer between $ 1 $ and $ 100 $ inclusive.
- $ a_i $ is an integer between $ 0 $ and $ T-1 $ inclusive $(1\ \leq\ i\ \leq\ N)$.
- For $1\ \leq\ i\ <\ j\ \leq\ N$, $a_i\ \neq\ a_j$.
Subtasks
Subtask $ 1 $ \[$ 100 $ points\]
- $N\ =\ 1$.
Subtask $ 2 $ \[$ 100 $ points\]
- No additional constraints.
Sample Explanation 1
In this case, sushi $ 1 $ can be taken at $4,\ 10,\ 16,\ 22,\ 28,\ \cdots$ seconds after arrival. The earliest is at $ 4 $ seconds.
Sample Explanation 2
The shortest time to take sushi $1,\ 2,\ 3$ is at $3,\ 7,\ 12$ seconds respectively.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分