Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
The Most Crowded
You are given a 2D matrix where 0 and negative
numbers represent the sea; any other number
represent the land. Adjacent land represents the
islands. The positive numbers are the
number of people living on that section of the island.
Question:
Write a program that defines the number of people
living on the most crowded island.Note:
Two land pieces may be adjacent if they
both contain a positive number and share one common
border on their four sides (right, left, up and down).
Input specification:
You will be given two numbers (n and m)
size of the island. Then each of the following
n lines contains m integers where the numbers
are between -9999 and +9999 and 1 ≤ (n and m)
≤ 100. And there is at least one positive number.
Output specification:
Show one integer.
Sample Input |
Sample Output |
4 4
1 -40 11 17
-3 -12 -32 4
-28 -22 -26 -11
8 10 -37 -36
|
32
|
Explanation:
There are three islands. And, the most crowded
island contains (11+17+4) 32 people.
Для отправки решений необходимо выполнить вход.
|