#P11068. 「QMSOI R1」 转转楼梯
「QMSOI R1」 转转楼梯
Background
The problem statement itself is the best background ().
Problem Description
Students do exercises every day, and they will pass through the spinning stairs.
The spinning stairs has steps. For step , it has a spinning value , where . In particular, .
For a step , if the spinning value of the next step is the same as it (that is, ), then we can walk down directly, costing second. Otherwise, we need to spend second to spin once to change the spinning value of the current step to , and then spend another second to walk down.
We need to do exercises for days. Every day, we walk from step to step .
Please compute the total time for these days that students spend on the spinning stairs.
Input Format
The input has lines.
The first line contains two numbers and .
The second line contains integers. The -th number represents .
Output Format
Output one integer in one line, representing the total time spent on the spinning stairs over these days.
3 2
0 1 0
9
Hint
Sample Explanation
On the first day, the sequence is . We walk steps and spin times, so the time is .
On the second day, the sequence is . We walk steps and spin time, so the time is .
Constraints
This problem uses subtasks for bundled judging. The score for each subtask is as follows: | Subtask | Range | Score | | :----------: | :----------: | :----------: | | | | | | | | |
For all data, and .
Translated by ChatGPT 5