Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official. ×

dhruvsomani's blog

By dhruvsomani, history, 9 months ago, In English,

Hey, I could not understand the solution of a problem and I need some help.

Here's the problem I am talking about. BOI 2009, Candy Machine.

In this solution, I understood the O(n^2) algo with OWSP. Can you please explain what the O(n log n) solution (the code part) is doing.

Why is it sorting on basis of (t + p, t — p)? And what is the binary search on?

Please help. :)

Thanks.

Read more »

 
 
 
 
  • Vote: I like it  
  • +5
  • Vote: I do not like it