HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


51117 - The Most Crowded

Guest
• Review clarifications (1)

Section problems

• 51069 - Last Digit of a Fibonacci Nu...
• 51130 - Permutation of Everything
• 51073 - Campus Tours for High Sch...
• 50994 - The Most Crowded Station
• 51148 - Circles
• 51123 - Mr. Li Criteria
• 51124 - Easy Tiae words
• 51145 - Graduation Exam
• 51117 - The Most Crowded
• 51146 - Popular Baby Names
• 51131 - Running After a Thief
• 51143 - Departments Competition
• 51132 - Problem Solving Competition
• 51118 - Place 7 to the 5th position
• 51121 - Complexity power of a nu...
• 51119 - Evaluating Prefix expressions
• 50541 - Binary to decimal

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