TACKLING KRISHNA MURTHY
All submissions for this problem are available.
Krishna Murthy ,the villain of the story plans to kill AbhiRam. As a part of it, he sends him a bouquet of flowers with a venomous scorpion inside the bouqet which bites him. Now, he needs an antidote to save his life and the clock is ticking.There are n hospitals in the city which have elixir to extend the time of effect of venom i.e., to extend the life time. The antidote is located in the nth hospital.He starts from the 1st hospital and reaches the antidote.A hospital has different value of elixir which gives him additional life.
Everytime he travels from ith hospital to jth hospital his life time decreases by h[i][j] and he can only travel it ith hospital to jth hospital only if he had enough life time i.e., life time is greater than cost of travelling.
AbhiRam can himself analyse the way once he knows the maximum health he can preserve. Help AbhiRam to find the value of maximum health.
- The first line consists of number of test cases 't'
- for every test case:
- The first line consists of number of hospitals 'n'
- The second line consists of array of integers indicating the elixir value of the ith hospital
elixir[i] = elixir at ith hospital
- The third input consists of nxn matrix indicating the decrease in life time
- h[i][j] = decrease of health for travelling from ith hospital to jth hospital
- for every test case print "Maximum health:'max health value'"if can reach the end else print "Abhi can't go"
- 1 ≤ T ≤ 20
- 1 ≤ number of hospitals ≤ 100
- 1 ≤ elixir value at hospital ≤ 1000
- 1 ≤ h[i][j] ≤ 1000
Input: 1 5 3 2 4 2 3 0 3 0 2 4 3 0 4 2 3 0 4 0 2 3 2 2 2 0 3 4 3 3 3 0 Output: Maximum health:5
Example case 1.
input : 1 3 1 2 3 0 4 4 4 0 4 4 4 0 output : Abhi can't go.
|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, SCALA, 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, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.