z-picerije
After a long deferment, the mayor of Z-city has allowed pizzerias to be opened in town. Pizzerias used to be unlawful because of health reasons (according to the mayor). The city is big, and suddenly there are pizzerias everywhere.
We can imagine the city like a matrix with NxN squares, where every square represents one block of the city. Every pizzeria only delivers pizza to the nearby blocks. Specifically, every pizzeria delivers pizza to every block that is at most K blocks away from block the pizzeria's location. Distance is determined by the minimum number of blocks that the delivery guy must take if he is going East/West or North/South (moving diagonally is forbiden in Z-city). For example, let's say that N=5 and a pizzeria is located at the block (3, 3). It can deliver to a 2 block distance at most. The following map shows where the given pizzeria delivers pizzas.
00X00
0XXX0
XXXXX
0XXX0
00X00Mr. Little Z loves pizza, so he wants to move to the block where he can have the greatest selection of pizzas (the block that has the maximum number of pizzerias delivering to it).
Help Mr. Little Z find that maximum. In other words, if he moves to the block with the greatest selection of pizzas, how many pizzerias will be able to deliver to his block?
5 2
3 3 2
1 1 2Output:
2Explanation:
The first pizzeria delivers pizzas to the following blocks:
00X00
0XXX0
XXXXX
0XXX0
00X00and the second one:
00000
00000
X0000
XX000
XXX00So the number of pizzerias that deliver pizzas to each block is:
00100
01110
21111
12110
11200So the maximum number is 2.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.