ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1112. Cover

WA #4 when using greedy (problem statement issue?)
Posted by Kuros 24 Dec 2014 20:58
If you're doing a greedy solution and you're sorting by the rightmost endpoints (B_i), you need to sort with the leftmost endpoints as second key. That is, if B_i == B_j, the shortest segment of i and j goes first in the list.

This basically means that longer segments are kept, so for inputs:

3
3 5
1 5
5 6

You would get result
2
1 5
5 6

instead of
2
3 5
5 6

which means you get a bigger covering of the set but the problem statement didn't mention this requirement.

Edited by author 24.12.2014 21:07
Re: WA #4 when using greedy (problem statement issue?)
Posted by Programmer 4 Sep 2015 20:54
there is no such information in statement