Failure-Man's blog

By Failure-Man, history, 9 years ago, In English

there are many problems like. https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3743

but every time i failed to solve this type. is there any algorithm to solve this type of problem????

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

| Write comment?
»
9 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

It's a greedy algorithm task. I used the following approach: sort intervals by their left border, and keep up the value of maximal prefix of covered points. To update it, find a new interval that will continue the prefix without no gaps, with maximal right border.

The code I got accepted with: #code.