Greedy question

how to appoach this question .

And why we taking input upto m-1 instead of upto n (Write a program that for each test case:
Reads the numbers x1, x2, …, xm-1 and y1, y2, …, yn-1)

Hello @divesh2000,

The bar has dimension mxn so, and if you’ll see the figure given in the question carefully, the values(i.e. the line drawn) are one less the columns and the rows resp.

Thus, it shouldn’t be n or m. Rather n-1 and m-1.

Hope, this would help.

Okay , I understand .But how to appoach thiis problem.I am trying to make logic from last 2 days.I unable to do that.
Help Me

hey, waiting for your reply.

Hey @divesh2000,

As the comments says greedy approach can help. So, try to think of one.

Let me know if you fails.
But, first try harder.