DMOPC '18 Contest 5 P2 - A Photography Problem

View as PDF

Submit solution

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

Problem type

When taking digital photos, it is important to get the proper exposure (brightness). A photo can be represented as a grid of N by M pixels, and the pixel in row i and column j has a brightness b_{i, j}, which can be any real number from 10^{-3} to 1 inclusive. If you average the brightnesses of all the pixels in a typical image, the result is 0.48. 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 C and multiplying all the pixel brightnesses in an image by C, 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 C that would correct its average brightness to 0.48. You may consider the image correctly exposed if the required C is within 10^{-5} of 1.


1 \leq N, M \leq 1\ 000
 10^{-3} \leq b_{i, j} \leq 1.0
It is guaranteed that no underexposed or overexposed image has a required C within 10^{-5} of 1.

Input Specification

The first line will contain two space-separated integers, N and M.
The next N lines will each contain M 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 C. Your answer will be considered correct if it has an absolute error of no more than 10^{-5}.

Sample Input 1

2 3
0.36 0.304 0.12
0.408 0.312 0.96

Sample Output 1


Sample Input 2

2 3
0.48 0.58 0.56
0.38 0.40 0.48

Sample Output 2

correctly exposed


There are no comments at the moment.