AriaB's blog

By AriaB, history, 5 years ago, In English

Hi, This is my code for this problem==>

https://www.spoj.com/problems/AGGRCOW/

code==> 54722487

I don't know why this doesn't return the correct answer please help!

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

may be because it is wrong task??

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

for example, if l=1 and r=3, m=2 — true
After this l=2 and r=3
But answer can be 3, so you have to check r as an answer after bin search before printing the answer — r can also be the answer.

»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

There are multiple bugs in your code.

Silly #1
Silly #2
Binary Search