The area formula is: where and .
The width is the distance between lines. The height is limited by the shorter line (water spills over the shorter side).
You want to maximize this product. The brute force approach checks all pairs in time. Can you do better?