TopCoder problem "Warehouse" used in SRM 177 (Division I Level Three)

Problem Statement

    Our warehouse is square, 200 feet on each side, with solid north and south walls. The east and west walls have sliding doors which allow trucks free entry and exit. Trucks come in a variety of sizes, but the width of each truck is an integer number of feet. Unfortunately the roof is supported by posts (of negligible size).

We want to drive big trucks in a straight line into the warehouse through the west wall and (after unloading and without changing direction) out through the east wall. Create a class Warehouse that contains the method feetWide that takes the positions of the posts as inputs and returns the width of the widest truck (of integral width) that can drive straight through without touching any posts (or the north or south wall). The positions of the posts are given by int[] x and int[] y: the i-th element of x and y gives the distance in feet east and north respectively from the southwest corner of the building to the i-th post.



Parameters:int[], int[]
Method signature:int feetWide(int[] x, int[] y)
(be sure your method is public)


-x has between 1 and 50 elements inclusive
-y has the same number of elements as x
-each element of x and y is between 0 and 200 inclusive


Returns: 199
The only post is at one of the corners of the building.
Returns: 79
The best path is due east, but the first and second posts are only 80 feet apart so the truck must be less than 80 feet wide.
Returns: 82
The best path is a little south of east, going between the two posts. The distance between the posts is sqrt(6800) =

Problem url:

Problem stats url:




lbackstrom , brett1479

Problem categories: