×

# [closed] Explanation for DLINE

 0 Can someone explain the Lunchtime DLINE problem test cases specially the last one from sample input and output. From the problem statement what I've understood is that we have to draw these lines parallel to y-axis, we can move pencil in two ways: (1) move it towards x axis both +ve and -ve x. (2) move pencil in +ve y only but first bring it to zero x coordinates. and 1 unit of time is used to move each changing x and y coordinates, we've a limit of time and to draw maximum complete line segments out of these operations. With this explanation (what I've understood) I couldn't solve the given test cases properly. Can someone explain it a bit. Just a small Hint or missing point would do the job. Thank you for your attention. asked 30 Dec '18, 08:32 350●10 accept rate: 13%

### The question has been closed for the following reason "The question is answered, right answer was accepted" by chandyshot 30 Dec '18, 15:03

 0 Holy fuck, I just realized we had to bring the x coordinate to 0 if we have to move the y coordinate. That makes the question a lot easier. Oh no, missed a +200 rating contest :( Last test case, you have segements [1, 2] and [3, 4] for y = 1, ans same for y = 2. First you move to y = 1 and then to x = 2, covering 1 line segment. You come back to x = 0. So you've now used 1 + 2 + 2 seconds. Next, move to y = 2, and move to x = 4. This costs 1 + 4 seconds, and you've covered 2 line segments at y = 2. A little explanation of sample cases wouldn't have hurt tbh. Basically, you've to start from the bottom and consider which lines to choose and which ones not to choose. I won't reveal how to do that (or at least that's what I think would be applied here). Good luck! answered 30 Dec '18, 10:29 63●2 accept rate: 7% Thanks, I missed it somehow. (30 Dec '18, 15:02)
 0 @arvindpunk would you mind expanding on the dp part of the solution cause what you said is O(n!) and would only fetch 10 points. answered 30 Dec '18, 12:18 4★karasu 23●4 accept rate: 0%

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×553
×41
×36

question asked: 30 Dec '18, 08:32

question was seen: 294 times

last updated: 30 Dec '18, 15:03