sahal's blog

By sahal, history, 3 years ago, In English

I couldn't find out bug in my code. Can anybody tell me what's wrong in my code or can anybody give me a testcase ?? Thanks in advance.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

The only advice for you is "Read the Problem Again"

»
3 years ago, # |
Rev. 3   Vote: I like it -9 Vote: I do not like it

You have assumed that movements in the x and y-axis are independent but it is not true. Let's say that we have segments s1, s2, s3, s4, s5, s6, s7. What your code does is it solves independently for s1, s3, s5, s7, and s2, s4, s6 and gives the minimum for each axis (Here odd index segments refer to one axis and the even index segment axis refers to another axis). But what the question says is; say you are using segment s5, then it is necessary that you have used segment s1, and s3 as well as s2 and s4. But your code does not consider this.

Question requirement: For using Si, the coefficients of segments 1 <= j < i must be at least 1 and the sum of coefficients at odd index must be N and at even indices must also be N.

Your code: For using Si, the coefficients of segments 1 <= j < i must be at least 0.

Sample Test Case:

1

6

100 1 100 100 1 100

Expected Output: 309

Your Output: 210