Блог пользователя watchdogs132

Автор watchdogs132, история, 8 лет назад, По-английски

Here is the link to the problem :http://codeforces.me/contest/1073/problem/D

Here is the link to my submission : http://codeforces.me/contest/1073/submission/44895822

It shows TLE on test case #8.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

while(temp>=*min_element(v.begin(),v.end()) That check works in O(N) every time, what leads to TL. Probably you should save *min_element in some variable to avoid that.