#K78767. Minimum Oven Temperature Adjustments
Minimum Oven Temperature Adjustments
Minimum Oven Temperature Adjustments
Tina is preparing to bake multiple layers of a cake. Each layer requires the oven to be set to a specific baking temperature. Initially, the oven is set to the temperature required for the first layer. For each subsequent layer, if the desired temperature is different from the current oven temperature, Tina must adjust the oven temperature.
The goal is to compute the minimum number of adjustments required to bake all layers in the given order. Mathematically, if the temperatures are given as \(t_1, t_2, \dots, t_n\), then the answer equals \[ \sum_{i=2}^{n} \mathbf{1}_{\{t_i \neq t_{i-1}\}}, \] where \(\mathbf{1}_{\{\cdot\}}\) is the indicator function.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(n\) which represents the number of layers.
- The second line contains \(n\) space-separated integers, where each integer denotes the desired baking temperature for each layer.
outputFormat
Output a single integer to standard output (stdout) representing the minimum number of temperature adjustments required.
## sample6
350 350 450 450 375 350
3