← CSES Better

The Middleman

INOI · 2007 · Indian National Olympiad in Informatics · INOI0702

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

grid · subgrid · optimization

The organizer’s problem statement is available at the official source link.

max profit square

Find the available square subgrid with maximum profit

Grid entries are field profits or losses; zero marks a field not for sale. The cells shown are symbolic, not a sample farm.

Problem grid; highlighted cells show the illustrated path
p11p12X
p21p22p23
p31p32p33
  1. 1

    Read the farm grid

    Each nonzero cell has a profit or loss; zero marks a reserved field.
  2. 2

    Choose a square

    The purchased fields must form a square subgrid containing no reserved cell.
  3. 3

    Maximize profit

    Find the allowed square whose cell values have the greatest total.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.