HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN254 Midterm > problem:


1. 51117 - The Most Crowded

CEN254 Midterm

Start: May.09.2017 at 02:05:00 PM
Finish: May.09.2017 at 03:02:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 1. 51117 - The Most Crowded
• 2. 51118 - Place 7 to the 5th position
• 3. 51119 - Evaluating Prefix express...
• 4. 50836 - Censored

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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.



Для отправки решений необходимо выполнить вход.

www.contester.ru