Embercode
✕
Object-Oriented ProgrammingCoding problems

Object-Oriented Programming: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 8 solved

  • A garden planner lists rectangular flower beds by their width and height in metres. Report the total area of all beds, and the position of the bed with the largest area.

    If two beds have the same largest area, report the earlier one.

    **Constraints:** 1 <= n <= 1000, 1 <= width, height <= 1000.

    Use a class Rect with an area() method. Store areas as long so the total cannot overflow.

    Input. First line n. Then n lines, each with a width and a height.

    Output. Two lines: the total area, then the position (starting at 1) of the largest bed.

    Example 1 input

    3
    2 3
    4 5
    1 10
    

    Output

    36
    2
    

    Example 2 input

    2
    7 7
    3 3
    

    Output

    58
    1