Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

BINLADEN - Bin Laden

Bin Laden the terrorist is hiding in a basement that has M floors below the ground. Each floor has N rooms. The rooms are separated by solid doors that are very hard to break. Each room has doors going to the room below and two rooms beside. From the ground, there are N doors going to N rooms of floor -1. Bin Laden is in the last floor (floor -M), room N (the rightmost room). Each door is made of diffrent kinds of metal, so they require different time to break.

Find the fastest way to go from the ground to Bin Laden's room or he will escape!

Input

  • Line 1: M and N
  • From line 2 to line 2M+1, even lines contain N numbers, odd lines contain N-1 numbers that are the time required to break the doors.

Output

A single number that is the minimum time to go to Bin Laden's room.

Example

Input
4 2
99 10
1
10 99
1
99 10
1
10 99
1

Output
44

+--99--+--10--+
|      |      |
|      1      |
|      |      |
+--10--+--99--+
|      |      |
|      1      |
|      |      |
+--99--+--10--+
|      |      |
|      1      |
|      |      |
+--10--+--99--+
|      |      |
|      1      |
|      |      |
+------+------+
We may go in zigzag.

Constraints

  • 1 <= M <= 2222
  • 1 <= N <= 10
  • Time to break the doors is in [0, 1000].

Được gửi lên bởi:VOJ Team
Ngày:2008-09-05
Thời gian chạy:0.200s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:VNOI Marathon '08 - Round 12/DivB
Problem Setter: Lê Đôn Khuê

hide comments
2021-05-27 17:59:13
Tham khảo: https://vnspoj.github.io/problems/BINLADEN
2020-02-25 11:43:45
đi 4 phía nhá :))
2019-10-08 15:06:06
dễ vl
2019-08-29 17:11:55
24 chứ sao lại 44 ?
2019-08-08 04:01:58
Solo Dr. Mundo thắng cho sub, tên nick AEC Dove
2019-05-28 15:49:18
1 đấm AC
from CBG_K28
2019-05-05 07:11:36
chạy trâu cũng ac
2019-04-04 10:39:42
chục đấm ac :V
2018-09-26 12:13:56
abc
2018-09-25 18:24:35
1 đấm AC ez game
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.