## DMOPC '18 Contest 5 P2 - A Photography Problem

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

When taking digital photos, it is important to get the proper exposure (brightness). A photo can be represented as a grid of by pixels, and the pixel in row and column has a brightness , which can be any real number from to inclusive. If you average the brightnesses of all the pixels in a typical image, the result is . Images whose average is lower than that are underexposed, and those whose average is higher are overexposed.

Most digital cameras have an exposure correction feature. By choosing a correction constant and multiplying all the pixel brightnesses in an image by , a darker or brighter image can be obtained. When applying a correction constant, if any pixel brightnesses become greater than 1, those values are "clipped" and reduced to 1.

Given an image, first determine if it is underexposed, overexposed, or correctly exposed. If the image is not correctly exposed, please find the that would correct its average brightness to . You may consider the image correctly exposed if the required is within of .

#### Constraints

It is guaranteed that no underexposed or overexposed image has a required within of .

#### Input Specification

The first line will contain two space-separated integers, and .
The next lines will each contain space-separated real numbers, the pixel brightnesses.

#### Output Specification

On one line, output the string underexposed, overexposed, or correctly exposed. If the image is not correctly exposed, output an additional line containing one positive real number, the required . Your answer will be considered correct if it has an absolute error of no more than .

#### Sample Input 1

2 3
0.36 0.304 0.12
0.408 0.312 0.96

#### Sample Output 1

underexposed
1.25

#### Sample Input 2

2 3
0.48 0.58 0.56
0.38 0.40 0.48

#### Sample Output 2

correctly exposed