Monocarp has found a treasure map. The map represents the treasure location as an OX axis. Monocarp is at $$$0$$$, the treasure chest is at $$$x$$$, the key to the chest is at $$$y$$$.
Obviously, Monocarp wants to open the chest. He can perform the following actions:
Monocarp can carry the chest, but the chest is pretty heavy. He knows that he can carry it for at most $$$k$$$ seconds in total (putting it down and picking it back up doesn't reset his stamina).
What's the smallest time required for Monocarp to open the chest?
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of testcases.
The only line of each testcase contains three integers $$$x, y$$$ and $$$k$$$ ($$$1 \le x, y \le 100$$$; $$$x \neq y$$$; $$$0 \le k \le 100$$$) — the initial point of the chest, the point where the key is located, and the maximum time Monocarp can carry the chest for.
For each testcase, print a single integer — the smallest time required for Monocarp to open the chest.
35 7 210 5 05 8 2
7 10 9
In the first testcase, Monocarp can open the chest in $$$7$$$ seconds with the following sequence of moves:
He only carries the chest for $$$2$$$ seconds, which he has the stamina for.
In the second testcase, Monocarp can pick up the key on his way to the chest.
In the third testcase, Monocarp can't use the strategy from the first testcase because he would have to carry the chest for $$$3$$$ seconds, while he only has the stamina for $$$2$$$ seconds. Thus, he carries the chest to $$$7$$$, puts it down, moves $$$1$$$ to the right to pick up the key and returns $$$1$$$ left to open the chest.
Name |
---|