RohitKadam244
BAN USER
- 19of 19 votes
AnswersYou have a grid of size N x M. Rows of the grid are numbered from 1 to N from top to bottom and columns of the grid are numbered from 1 to M from left to right. So, top-left corner is indexed as (1,1) and bottom-right corner is indexed as (N,M).
- RohitKadam244 in India
Cost of visiting a cell at index (i,j) is denoted by C[i][j]. Cost of changing the direction of your facing at index (i,j) is denoted by P[i][j].
You have to start from cell (1,1) and reach to cell (N,M) with minimum cost. At cell (1,1), you can either face towards 'Right' or face towards 'Down'. At any point of time, you can either face 'Right' or face 'Down'.
There are 2-types of moves allowed:
1. Move one cell towards the facing direction i.e. if you are facing 'Right', you can move one cell 'Right' or if you are facing 'Down', you can move one cell 'Down'. The cost of visiting cell (i,j) will be C[i][j].
2. Change the direction of facing i.e. if you are facing 'Right', you can now face 'Down' or if you are facing 'Down', you can now face 'Right'. The cost of changing the facing direction at cell (i,j) will be P[i][j].
Find the minimum cost to reach (N,M) after starting from (1,1).
Constraints:
1 <= T <= 3
1 <= N,M <= 1000
1 <= C[i][j], P[i][j] <= 1000
Input Format:
First line of each testfile contains T, the number of test cases.
In each testcase, First line contains two inetgers N and M denoting the dimensions of the grid.
Next N lines contains M integers each denoting the cost matrix C.
Next N lines contains M integers each denoting the cost matrix P.| Report Duplicate | Flag | PURGE
Replelarolen76, Android test engineer at Alliance Global Servies
As a Public finance economist I am working at Liberal company . Here I will take a leadership role in the ...
RepPearlBenda, Associate at Accenture
I am Pearl , a Power Plant Operator with in-depth knowledge of all aspects of operation and maintenance and 9 years ...
Repcandacebdemars876, Android Engineer at A9
Hello, I am the Skills Training Coordinator. A skills training coordinator works with human resources and management to identify training ...
RepVictoriaMitchell, Animator at ABC TECH SUPPORT
I am an Analysis Manager.I have 7 years of experience in leveraging data analysis to develop. And I love ...
RepJeanSwest, Data Engineer at Achieve Internet
I am a nuclear power reactor operator who is responsible for the flow of energy at a power plant. I ...
RepCallaRita, techsupport at Knowledge Systems
Hi, I am an Administrative person . It is to develop and sustain an early childhood organisation. I was a teacher ...
RepNancyNieves, Accountant at ABC TECH SUPPORT
Hey I am a HR Trainer. I have been working in this field for almost 3 years. I am very ...
RepJamesDeal, Animator at Absolute Softech Ltd
My name is JamesDeal. I am working at Integra Investment Service as a Library aide . It's been almost 5 ...
Replegabesg, Android Engineer at ASU
My name is JoeColeman . I am working at Rite Solution as a Data entry keyer . It's been almost 10 ...
RepDavidJohaan, Digital marketing Experinced at Abs india pvt. ltd.
I am David , a scanner operator for seven years in the industry Paearb. Six months ago , I’d an injury ...
RepAlizaMaurice, Applications Developer at Absolute Softech Ltd
Aliza, a photojournalist with six years of experience capturing powerful images that tell stories. Have connections with a Vashikaran Specialist ...
RepYorgaKeaton, Area Sales Manager at AMD
Hi, I am Yorga , Information record clerk perform clerical duties that include filing and organising records and collecting information. My ...
RepSteveParrish, Associate at ABC TECH SUPPORT
I am Steve , a Food Service Worker with a demonstrated experience in preparing various meals, maintaining kitchen equipment, cleaning the ...
RepJessicaHanda, Front-end Software Engineer at ABC TECH SUPPORT
Jessica , hard-working Packer with a strong determination to finish all assignments in a timely manner. I have joined a few ...
RepShaneFord, Associate at ABC TECH SUPPORT
ShaneFord , Uniformed police officer working at Kash n' Karry here i Assists in the investigation of crimes and/or suspected ...
RepEthelRector, Animator at AMD
EthelRector is a clerk working at Egghead Software with lots of experience . exploring new things Black magic to break up ...
RepNiaNorna, Analyst at ADP
I am an established career journalist with 15 years of writing and copy editing experience in the newsroom. Seeking to ...
Repeleanormzavala63, Android Engineer at 247quickbookshelp
Hello I am a publicity agent, I have completed all my studies from Brighton. And now-a-days I am working as ...
Repjeannetucker768, Analyst at 247quickbookshelp
Hello I am a computer programmer. I have completed all my studies from New York. Currently I am working in ...
RepJudeSandin, Associate at Absolute Softech Ltd
My name is JudeSandin . I am working at Bold Ideas as a Web designer. With 5 years experience . I am ...
RepSuziCorni, Accountant at A9
I have strong critical and analytical skills with reading, writing, and comprehension. I have exceptional speaking skills without losing train ...
RepAveryPerez, abc at 8x8
I am a self-driven and motivated librarian skilled at providing excellent public service to students and staff, managing the library ...
RepKeciaFowler, Area Sales Manager at Auto NInja
My name is Kecia and I am a results-oriented Real Estate Appraiser Trainee with a strong determination to perform great ...
RepBellaReyes, Android Engineer at ADP
I am a creative and dedicated photo editor with experience in photojournalism and marketing material development. I have a proven ...
Repheldagale, Backend Developer at ASU
Helda , an outgoing Library Assistant capable of working independently in a busy library environment. Great team player adept at performing ...
RepNaomiSmith, Integration Software Engineer at ASU
Naomi , a strategic Merchandise Buyer with over 4 years of professional experience in merchandise planning and purchasing positions. Advanced presentation ...
Repminniermontano, Android test engineer at 8x8
Hello my name is Minnie and i live in california. And I'm working as a paymaster at Tech Hifi ...
Repswammesha, Blockchain Developer at ADP
As a machine operator at Star Bright Investment Group it's been almost 10 years . here i learn different things ...
RepMyraGreen, Accountant at 8x8
I am a dedicated secretary with 2 years of experience excited to join MCL to become a key player in ...
RepEzraDavis, abc at A9
I am a hardworking and disciplined newly-certified architect with internship experience in designing commercial buildings and creating accurate 2D and ...
Reppetersmith36788, Animator at ABC TECH SUPPORT
I am working at Eden Lawn Service as a Bridge and lock tender . Here I manage all the things like ...
RepJoshuaChiles, Android test engineer at Accolite software
I am Joshua Information design is an efficient and effective understanding of the information. The term has come to be ...
RepAasiHarris, abc at 8x8
I am a creative designer with innovative ideas and a unique approach to visuals. I am also a skilled painter ...
Repsuegdiaz765, Android test engineer at 247quickbookshelp
My name is Sue and I am a Specialist. We Specialist employees are responsible for specific tasks or activities in ...
Repdennisrichar76, Accountant
I am a resourceful and seasoned Mechanical drafter with a strong customer service and industries. I have a strong knowledge ...
Reppamelajones9873, Area Sales Manager at Facebook
Hello I am Pamela Jones. I am an Animal Control Worker Here, Animal control officers are generally employed by a ...
RepAnaCardenas, Android Engineer at Allegient
Working as a Window clerk at EnviroSource Design for almost 10 years . Here I help people to guide . End a ...
Repggroverwmiller, Android Engineer at 247quickbookshelp
Hello I am a Budget officer with 5 years of experience. The Budget Officer implements budgeting and financial record keeping ...
RepMiguelCortez, Accountant at Apache Design
I am a webmaster and a person responsible for maintaining one or more websites. I spend most of my time ...
RepAnnetteOwens, Email Customer Service at Axiom Sources
Hi , I am Annette, a Data Processor with a comprehensive knowledge of data management and analysis. As I am a ...
Repmanduj972, Executive chef at Neptune, NJ 07753
Hello, I am Mandu and I completed all my study from Neptune. today I am working as an Executive Chef ...
Repcheryljnewsome, Android Engineer at ABC TECH SUPPORT
Hello, my name is Chery and I am a Graphic designer. We are Graphic Designers create visual concepts to communicate ...
RepAmyuDiaz, abc at 8x8
Professional cost accountant with several years of experience in accounting tasks such as maintaining inventory, calculating liability, budgeting labor costs ...
RepYuvaanBrown, abc at AMD
I am working as an art director in a lomni company. I have expert knowledge of adobe creative suite in ...
RepCathyCruz, Analyst at AMD
I am a highly responsible service station manager seeking an opportunity to work in a top company oy aid in ...
Repzkate584, Android test engineer at 247quickbookshelp
Zara , a Publisher with a record of extraordinary achievements in increasing sales and circulation, discovering and launching new books and ...
Repvickidsmithv, Android Engineer at 247quickbookshelp
Hello, I am a Managing editor. I have completed my studies from New York. Apart from this, whenever I am ...