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

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


51100 - Minimum time to exit building

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

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

• 51087 - Are they the same?
• 51091 - Guess the number - 1
• 51015 - Student Scholarships
• 51008 - Sum of Regional Maxes
• 51020 - Number of nodes removed
• 51141 - Most valuable stock items
• 51014 - Nine Men's Morris game
• 51019 - Finding the hidden message
• 51100 - Minimum time to exit b...
• 51089 - Multiply a row and add it to ...
• 50525 - Ordering Pizza
• 50531 - File Decryption
• 50360 - National Elections
• 50469 - Letter Grades
• 50468 - Draw Matrix - 2
• 51099 - Mr. Monk
• 51012 - Palindrome-k

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

Если у вас есть предложения или пожелания по работе 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