The land Beyond the Wall
Practice
0 (0 votes)
Medium Hard
Problem
6% Success 115 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

The land beyond the wall is in the form of a matrix. It has 3 rows and N columns. The white walkers along with the Night King is on the move from cell (1,1) to cell (3,N) and in their way, they will be raising their army (which consists of dead peoples called wight). The Night King has directed the white walkers that they won't be visiting any cell more than once. Each cell has some wight i.e A(i,j) which can be negative as well (indicating their is fire in that cell and White walkers will lose that many wight in the fire). You are given the matrix of the land beyond the wall. You have to find the maximum number of wight with which the white walkers will be reaching their destination.The white walkers can move in any directions but it cannot go to any cell more than once.

NOTE: Total number of wights includes the wights of the cells (1,1) and (3,N).

Input:

First line of input consists on N indicating number of columns in land beyond the wall. 3 lines follow having N numbers each.

Output:

Print the maximum number of wights possible for the white walker's army.

Constraints:

1<=N<=10^5

(-10^9)<=A(i,j)<=(10^9)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
14 votes
Tags:
AlgorithmsIntroduction to Dynamic Programming-22D dynamic programmingDynamic Programming