JVirak's blog

By JVirak, history, 8 years ago, In English

Hey guys I had about 6 wrong submissions for this question http://codeforces.net/problemset/problem/760/B. On 4 of them I got timeout errors and 2 a wrong answer on test-cases 1. Now the contest is over I got to go over these with the test-cases visible. As usual test case 1 was the first example, which turns out to run perfectly fine on my laptop (gives right answer don't think it takes too long).

It turned out I had the same basic idea as the tutorials, figure out how many pillows it will take for Frodo to have p and then do binary search. I have no trouble believing that I made a mistake on either binary search or the number of pillows function itself (i.e. missed an edge case) which is why I kept resubmitting.

Anyway this http://codeforces.net/contest/760/submission/24047827 gives me the wrong answer on test case 1, producing 10000000 on the judge (the giant upper bound I set for my binary search). However on my home laptop it gives 2 (the correct answer). This gives me two related questions. 1. What is going on here? and 2. What does this do on other people's machines. (I'd be very grateful to anyone else willing to run it).

Also this http://codeforces.net/contest/760/submission/24048597 version of the code gives me a timeout error. Again on my local machine it manages to do the job (at least on test case 1). While I'm not sure exactly how long it takes to run (runtime output includes typing time) it seems almost instant.

Obviously I'd like to avoid this next time so if anyone can help me find this error I'd really appreciate it.

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

»
8 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Well yeah http://codeforces.net/contest/760/submission/24047827 gives output 2 on my system as well on test case 1

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

    Thanks for taking the time to run it and reply. Wish I knew what was going on here.

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it +14 Vote: I do not like it

      read again your tot function. Don't you feel you forgot to add something in there?