Блог пользователя LaFolle

Автор LaFolle, 12 лет назад, По-английски

I solved it using sorting + dp. In tags it is 'binary search' + 'sorting'. Couldn't think of binary search solution.

BTW, size limit is 10^6 and not 10^5.

  • Проголосовать: нравится
  • -8
  • Проголосовать: не нравится

»
12 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

First of all I think it will be better to write to link and not only problem name (maybe I'm wrong, but I do not know how to search problems by name).

Here is the link (I think you are talking about): 101C Queue.

Maybe I'm looking on different problem, but tags I see are: "constructive algorithms", "greedy", "sortings" and limit (for h_i) in this problem is 10^9.

»
12 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

For each position on the queue calculate the youngest person from that position to the end. You can do binary search to find the farthest place on the queue such that this min is less than the age of the current walrus, which is the position of the farthest walrus that is younger than the i-th one.