cabins. Stoves are placed along the same road at the coordinates in stoves. All stoves are identical: a stove with reach r standing at point p warms every cabin whose coordinate is between p - r and p + r inclusive.
Find the smallest integer reach r such that every cabin is warmed by at least one stove. Several cabins or stoves may share a point, and a cabin may stand at the same point as a stove.cabins=[2, 9, 14], stoves=[6, 12] → 4
The nearest stove to cabin 2 is at 6 (distance 4), to cabin 9 it is 6 or 12 (3), to cabin 14 it is 12 (2). A reach of 4 is needed.
cabins=[5, 5, 7], stoves=[5, 7] → 0
Every cabin stands right next to a stove, so a reach of 0 is enough.
cabins=[1, 100], stoves=[30] → 70
cabins=[2, 9, 14], stoves=[6, 12]
4
Run checks the first 3 tests in your browser. Submit checks all 110 tests on the server, hidden ones included.