Here is the link to the problem :http://mirror.codeforces.com/contest/1073/problem/D
Here is the link to my submission : http://mirror.codeforces.com/contest/1073/submission/44895822
It shows TLE on test case #8.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 170 |
2 | Um_nik | 162 |
3 | atcoder_official | 160 |
3 | maomao90 | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 152 |
9 | luogu_official | 152 |
Why does this binary search show TLE ? Problem D: Educational Codeforces Round 53 (Rated for Div. 2)
Here is the link to the problem :http://mirror.codeforces.com/contest/1073/problem/D
Here is the link to my submission : http://mirror.codeforces.com/contest/1073/submission/44895822
It shows TLE on test case #8.
Название |
---|
It seems that you increment 'c' by 1 for every candy you buy. As the solution can be 1018, you will not finish a calc(mid) invocation in time when mid is large.
Also, 'high' starts at 3e10, and you look for a solution in [low, high]. But the solution can be way larger than that.
Yes, it works for the test#8 though , but I get TLE on test#9(Link: https://mirror.codeforces.com/contest/1073/submission/44903513 ). Thanks anyways. On a side note , do you think my code can be optimized more to get it accepted ? or do I need to change my approach entirely?
I'd suggest storing values that are less or equal than T in a set. That way you won't be spending time considering bigger elements. But, I'm still not sure if that will get AC. Probably you should give up binsearch and think of another idea.
The binary search part is unnecessary: 44923323
In a case like
Your calc function runs in O(T) time.