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

Разделы > Linear Data Structures: Arrays > задача:


51100 - Minimum time to exit building

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

Задачи раздела

• 50989 - Rectangles and Points
• 51020 - Number of nodes removed
• 50932 - Shifting rows and columns
• 51141 - Most valuable stock items
• 51014 - Nine Men's Morris game
• 51019 - Finding the hidden message
• 50497 - Falling Bricks - Revisited
• 50933 - Sum of the Biggest Neighbors
• 51100 - Minimum time to exit b...
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51089 - Multiply a row and add it to ...
• 50874 - Apartment Building Adminis...
• 50531 - File Decryption
• 51012 - Palindrome-k
• 50469 - Letter Grades
• 50525 - Ordering Pizza

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

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

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

Minimum time to exit building

Question: Police is running after a thief who is trying to escape out of a building. Because, he wants to go out of a high building, he goes only down, left, or right to the rooms which he did not visit before. There are obstacles in the rooms which slows him down. The number in every cell represents the amount of time required to pass from the room. And, he searches the fastest way (the path with the smallest total value). Write a program that finds the path with the smallest value.

Input specification: Firstly, you will be given two integers (n and m) where n is the size of 2D square matrix and m is the starting column from the top row. Then, in the following n lines you will be given n integers where 1 ≤ (n and m) ≤ 20 and the numbers in the matrix are less than 1001.

Output specification: Show one integer: the total time required to go out of building.

Sample Input Sample Output
4 1
6 5 7 9
10 3 1 7
2 7 4 2
8 8 1 2
20

Explanation: He starts from the first column. Then, he can follow the path 6 + 5 + 3 + 1 + 4 + 1 = 20



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

www.contester.ru