All Tracks Problem

Joey and the journey to become a film star
Tag(s):

Easy-Medium

Problem
Editorial
Analytics

Joey and the journey to become a film star

enter image description here

We all know how much Joey loves acting. Now his dream to become an actor is really close. All that is left is to pass the forest of DEATH. Forest of death is a place that takes away your life energy and ultimately you die. This forest also has many potions to restore your energy. The only way to cross the forest is by collecting maximum potions. Joey can start his journey from any location at head of forest (1st row) and has to reach the tail of forest (last row). Joey wants to know the maximum amount of potion that he can get when the journey is finished. from [i,j] , he can go to [i+1,k] iff abs(j-k) is a prime.

Input:

The first line has N ans M (Rows and columns)

Then N lines follows each having M values denoting amount of potion at that location.

Output:

Maximum amount of potion at the end.

Constraints:

\( 1\leq N , M \leq 800 \)

\( 1\leq F[i][j] \leq 10^{5} \)

Problem Setter - Satyarth

SAMPLE INPUT
3 3
1 2 3
4 5 6
7 8 9
SAMPLE OUTPUT
16
Time Limit: 0.5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:
Notifications
View All Notifications

?