#K37322. Minimum Operations to Achieve \(a < b\)
Minimum Operations to Achieve \(a < b\)
Minimum Operations to Achieve (a < b)
You are given two integers \(a\) and \(b\). Your task is to determine the minimum number of operations required to ensure that \(a < b\). In a single operation, you are allowed to perform one of the following actions:
- Add 1 to \(a\) (i.e., \(a = a + 1\))
- Subtract 1 from \(b\) (i.e., \(b = b - 1\))
If \(a < b\) initially, no operations are needed and the answer is 0. Otherwise, the minimum number of operations required is \(a - b + 1\). This is because after performing \(a - b + 1\) operations, the inequality \(a < b\) will hold.
inputFormat
The input begins with an integer (t) ((1 \leq t \leq 10^5)), representing the number of test cases. Each test case consists of a single line with two space-separated integers (a) and (b) ((-10^9 \leq a, b \leq 10^9)).
Example:
4 3 5 6 4 1 1 -2 3
outputFormat
For each test case, output one integer on a new line — the minimum number of operations required to achieve (a < b).## sample
1
3 5
0
</p>