Lucky And Growth
All submissions for this problem are available.
Presently Lucky is in a friend circle at NIT Rourkela where everybody makes fun of him because of his short height. So he asked his friend Debasish to help him. Debasish left him in a room containing N * M grid where each cell (i, j) contains height increasing capsule H(i, j). Lucky starts at (0, 0) and he can move to any of it's adjacent cell in east, south and south - east direction only with a jump cost of 1. But he can move to any adjacent cell where i should increase and j should decrease or vice - versa with no jump cost. Can you help him in finding the minimum cost at which he can increase his height by at least K.
- First line contains T denoting the number of test cases.
- First line contains number N, M, K.
- Next N lines contains M numbers for grid H.
A number representing minimum cost to increase height by K. If it is not possible print -1.
- 1 <= T <= 10
- 2 <= N, M <= 50
- 1 <= K <= 10000
- 0 <= i < N
- 0 <= j < M
- 0 <= H(i, j) <= 100
Input: 1 4 4 28 0 1 2 3 1 2 3 4 2 3 4 5 3 4 5 6 Output: 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions