RestingRajarshi's blog

By RestingRajarshi, history, 6 years ago, In English

this is the pdf link, see p2 (mobiles).

SOLUTION : binsrch on answer and check. however my code is giving error (WA). its quite small, so hopefully it will be readable.

Any help is appreciated.

PS: main function only has the binary search part. Check function checks if the dist chosen will cover the entire line. i have removed the redundant segments using deque using the fact that the points are already sorted by x coordinate

code
  • Vote: I like it
  • -5
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by RestingRajarshi (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by RestingRajarshi (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by RestingRajarshi (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I think that part "I have removed the redundant segments using deque using the fact that the points are already sorted by x coordinate" is incorrect.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    let s[i] = starting of range and e[i] = ending of range. if j > i and s[j] < s[i] then obviously e[j] > e[i] right? so the ith interval is completely overlapped by the jth interval.

    Thats why i removed.