|  | 
|  | 
| вернуться в форум | WA #4 when using greedy (problem statement issue?) Послано Kuros  24 дек 2014 20:58If 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?) there is no such information in statement | 
 | 
|