#K74932. Indentation Adjustment
Indentation Adjustment
Indentation Adjustment
You are given a sequence of indentation levels for a piece of code consisting of n lines. Your task is to determine the minimum number of operations required to adjust the indentation level of a specific line to a desired level. In one operation, you can increase or decrease the indentation level by 1.
Formally, let the current indentation level on the given line be \( a \) and the desired indentation level be \( b \). The answer is \(|a-b|\), which represents the absolute difference.
For example, if the current indentation is 1 and the desired is 3, you will need 2 operations.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains an integer \( n \) which is the number of lines.
- The second line contains \( n \) integers separated by spaces representing the indentation levels of each line.
- The third line contains two integers:
line
(the 1-indexed line for which the change is desired) anddesired_level
(the target indentation level).
outputFormat
Output a single integer to standard output (stdout) which is the minimum number of operations required to adjust the indentation level of the specified line to the desired level.
## sample4
0 1 2 3
2 3
2