Vrijeme: 23:17

From Serbia, with love #4

Cijeli brojevi od 1 do 64 smješteni su u nekom poretku u mrežu ćelija dimenzija 8\times8, pri čemu se u svakoj ćeliji nalazi po jedan broj. Neka je a_{i,j} broj smješten u ćeliju u i-tom redu i j-tom stupcu, i neka je M zbroj apsolutnih razlika između susjednih ćelija. Odnosno, M = \sum_{i=1}^8 \sum_{j=1}^7 (|a_{i, j+1} - a_{i, j}| + |a_{j+1, i} - a_{j, i}|). Koja je najveća moguća vrijednost M?
The integers from 1 to 64 are arranged in some order in an 8\times 8 grid, with one number in each cell. Let a_{i,j} denote the number placed in the cell in the i-th row and j-th column, and let M be the sum of the absolute differences between numbers in adjacent cells. That is, M = \sum_{i=1}^{8} \sum_{j=1}^{7} \left( |a_{i,j+1} - a_{i,j}| + |a_{j+1,i} - a_{j,i}| \right). What is the greatest possible value of M?