Question on Round393 Div2 Question B

Правка en1, от JVirak, 2017-01-23 08:55:55

Hey guys I had about 6 wrong submissions for this question http://mirror.codeforces.com/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://mirror.codeforces.com/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://mirror.codeforces.com/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.

Теги beginner, #timelimit, wrong answer on test 1

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский JVirak 2017-01-23 08:55:55 1615 Initial revision (published)