ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN112 Questions 2016 > задача:


15-HW-3. 50933 - Sum of the Biggest Neighbors

CEN112 Questions 2016

Старт: 30.мар.2016 в 15:10:22
Финиш: 01.апр.2016 в 05:00:00
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (3)

Задачи турнира

• 15-FE-1. 50992 - Top K Obese Classes
• 15-FE-2. 50993 - Products in store
• 15-FE-3. 50994 - The Most Crowded...
• 15-FE-4. 50995 - Group Average
• 15-FE-6. 50989 - Rectangles and Points
• 15-FE-7. 50990 - Two Neighbors
• 15-FE-8. 50991 - Intersecting Circles
• 15-HW-2. 50932 - Shifting rows and...
• 15-HW-3. 50933 - Sum of the Bi...
• 15-HW-4. 50934 - Selling Cars
• 15-HW-5. 50935 - Max Discount
• 15-MdtE-1. 50915 - Trip to Korca
• 15-MdtE-2. 50916 - Ascending Num...
• 15-MdtE-3. 50913 - Manhattan Distance
• 15-MdtE-4. 50917 - Descending Nu...
• 15-MdtE-5. 50912 - Trip to Librazhd
• 15-MdtE-6. 50914 - Buy 3, Pay 2

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Sum of the Biggest Neighbors

Math teacher of your brother gave a homework to learn and to follow directions. You want to write a program to assist your brother. The professor gives a 2D array, and then, he also gives some directions to move around the table. Your brother has to find the biggest of 4 neighbors for every stopping point and output sum of the biggest neighbors. If any neighbor is not in border, it's not calculated. If any stopping point is out of border (out of the limits of 2D array) he shows the current sum until that point.

Question: Write a program that reads a 2D array and k instructions. The program starts always upper left corner (1,1) and should output sum of the biggest neighbors.

Input specification
You will be given two integers in the beginning: the number of rows and columns. Then, you will be given a 2D array. The next line contains an integer (k) the number of instructions. The following k lines will have two information:

  • a char that shows the direction: U (Up), D (Down), R (Right), or L (Left)
  • a number showing the number of moves from the current position on the given direction.
where 0 ≤ rows and columns ≤ 100 and 0 ≤ k ≤ 2,000.

Output specification:
Show one integer.

Sample Input I
5 4
9 8 8 1
4 2 4 2
2 10 9 9
1 6 4 2
5 10 6 4
5
D 3
R 3
U 3
R 4
L 2
Sample Output I
23

Explanation: It starts from (1,1) and moves Down 3 (1,4). The numbers around are 5, 6 and 2. And thus, the biggest neighbor is 6. Then, he moves 3 cells to the right (4,4). The biggest number among the neighbors is 9. Then it moves 3 cells up. and the biggest among the neighbors is 8. He reaches out of borders after moving 4 cells right. So, the operation ends. And as a result, sum of the biggest neighbors is 23 (6 + 9 + 8).



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

www.contester.ru