# DCP-6: Thief of deVillage!!! Back to All Problems

Easy Divide and Conquer > Dynamic Programming

In a reputed company our team has been working on a game project named **‘Thief of deVillage!!!’**. Sounds thrilling huh! ;-). The game is very simple. You just have to roam around the treasure pyramids of deVillage and steal the treasures buried there for centuries!! ![pyramid][1] As you can see in the figure above that this pyramid of deVillage contains four floors with some cells inside them. The number of cells in a floor = the number of cells in its upper floor + 1. All the cells are full of plenty of gold coins, **C**. Your goal in this game is to grab the maximum possible coins m from these mysterious pyramids. As these pyramids are very special so your journey through them will also be very special. You have to begin your journey from the top cell of the top floor of a pyramid and finish it at any of the bottom cells of the bottom floor. **Game Instructions:** There are only two buttons in this game - the left move button and the right move button. From any position (cell), pressing the left move button will move you to your lower left cell and pressing the right move button will move you to your lower right cell. Remember that you can never go back to the upper floors while moving. You can only choose between going left or right lower cells. As you move from cell to cell the coins at each cell will be deposited to your account. You have to obtain the maximum possible balance from each pyramid to achieve 3 stars (***) on each stage of the game. Now you need to calculate the maximum possible balance **m** for a stage. Input: ------ Each test case starts with a single integer **N (1 ≤ N ≤ 100)** which represents the number of floors in a pyramid. Then there will be N Lines denoting the floor of the pyramid from top to bottom. Each line will contain some integer values separating by spaces representing the number of coins, **C (1 c 100)** in each cell of the respective floor. Two successive cases are separated by a single new line. Output: ------- For each test case, print **“Output: m”** (without quotation) where **m** denotes the maximum possible account balance one can make in a stage. Sample Input ------------ 4 3 21 23 05 13 15 02 18 09 04 5 92 31 72 85 31 21 25 90 22 08 30 50 54 86 88 Sample Output ------------- Output: 57 Output: 352 **Explanation of First Test Case:** *Please look at the given figure in this problem.* *3 + 23 + 13 + 18 = 57* [1]: https://s3-ap-southeast-1.amazonaws.com/devskillimagestorage/questionimages/1449455f-fc57-c68b-1be6-08d2e1538f41_a45c2c3af6374e55b0be433dca3046a2_W650xH414.png

### Problem Limits

 Language Time Limit (seconds) C 1.00 C++ 1.00 C++14 1.00 C# 2.00 Go 2.00 Java 2.00 JavaScript 2.00 Objective-C 2.00 Perl 2.00 PHP 2.00 Python 2.00 Python3 2.00 Ruby 2.00 VB.Net 2.00

# 82/163

Solve/Submission

### Ranking

# User Language Timing
01 feodorv C 0.02s
02 Morass Cpp14 0.04s
03 a_rahman Cpp14 0.07s
04 Siddartha Cpp14 0.07s
05 markII Cpp14 0.07s
06 Dragon_162 Cpp14 0.08s
07 ProMAGFAT Cpp14 0.08s
08 MAHRahat Cpp14 0.08s
09 Masum_ice Cpp14 0.08s
10 Ishrak Cpp14 0.08s
11 umli Cpp14 0.08s
12 Bruteforcekid Cpp 0.08s
14 prodip_bsmrstu Cpp 0.09s
16 khmahbub20 Cpp 0.10s
17 anik_JU Cpp14 0.10s
18 pulak_ict_mbstu Cpp 0.10s
19 Jubayer_Hasan Cpp14 0.10s
20 subhashis_cse Cpp 0.10s
21 traveller42 Cpp 0.10s
22 tariqiitju Cpp14 0.10s
23 rithu Cpp14 0.11s
24 Jisancse Cpp 0.11s
25 Dark_Ocean Cpp14 0.11s
26 sakib_muhit Cpp14 0.11s
27 sb_rithu Cpp14 0.11s
28 ash12 Cpp14 0.12s
29 rashedul007 Cpp 0.13s
31 shameemreza Cpp 0.13s
32 Dinar Cpp14 0.16s
33 nazmul_bzs Cpp14 0.17s
34 AbirRahman Cpp14 0.18s
36 dip_BRUR Cpp14 0.20s
37 nazmulasha Cpp14 0.25s
38 dmehrab06 Cpp14 0.36s
39 ih_hira Cpp14 0.38s
40 froghramar Cpp14 0.46s
41 njrafi Cpp14 0.48s
42 sazal_dev Cpp14 0.48s
43 mahbub07 Cpp14 0.49s
44 anowar1112 Cpp14 0.55s
45 Alim14 Cpp14 0.56s
46 rayhan50001 Cpp14 0.57s
47 KIRIN_36 Cpp14 0.58s
48 haasib Cpp14 0.65s