branimir116's blog

By branimir116, history, 9 years ago, In English

Good day everybody,

I've been going true some old problems and I've found this problem: 453B - Little Pony and Harmony Chest

And I've been wondering why can't I just cout [sum of (A0,A1,A2,...,AN) — N] and cout 1, N times ?

I'd be harmony sequence and it'd minimaze the sum.

I tryed subminting solution that did that but it failed.

Can someone explain why is this wrong?

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

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

because there might exists better solution — one with smaller sum of differences. Your goal is to minimize sum of |bi-ai|.

»
9 years ago, # |
  Vote: I like it +9 Vote: I do not like it

You have to minimize sum of absolute values, not an absolute value of sum.

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

Yea I see thanks, I didn't see that abs bracket.