22. Diana drew a rectangular grid of 12 squares on squared paper. Some of the squares were then painted black. In each white square she wrote the number of black squares that shared an edge with it (a whole edge, not just a vertex). The figure shows the result. Then she did the same with a rectangular grid of 2 by 1009 squares. What is the maximum value that she could obtain as the result of the sum of all the numbers in this grid?

A 1262
B 2016
C 2018
D 3025
E 3027
22. D Each black square (except at the endpoints) has at most 3 neighbours so can add a maximum of 3 to the total. This maximum is achieved with the top configuration shown. This gives an average of 3 per column (excluding endpoints). It is possible for a column to have a higher total than three by having two twos (as in the bottom diagram). However, this is at the expense of a total of
zero from its adjacent columns, giving a column average of only 2 . Hence the maximum is achieved in the first diagram, giving a total of $1007 \times 3+2 \times 2=3025$.