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

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

in problem F the binary search approach why is this equation wrong with large numbers but it works with small numbers

number of time we use current attack = ceil(mid/(c[i]+1))

Update : it's because of the cool down you don't need to wait c[i] round to hit again you actually wait c[i]-1 round so ceil(mid/c[i]) is correct

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

»
5 недель назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

its cause there is a potential overflow for the attack variable. consider h=2e5,n=2e5,all attacks 1 and cooldown 2e5. Using a break should solve the problem. PS i got hacked too

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

ok I figured it now it's because of the cool down you don't need to wait c[i] round to hit again you actually wait c[i]-1 round

so ceil(mid/c[i]) is correct

  • »
    »
    5 недель назад, # ^ |
    Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

    For $$$i$$$-th attack you can hit in rounds $$$1$$$, $$$c[i]+1$$$, $$$2c[i]+1$$$, $$$3c[i]+1$$$, ..., $$$kc[i]+1$$$, so if you are currently at round $$$T$$$, you can hit max of $$$\Bigl\lfloor \frac{T-1}{c[i]}\Bigr\rfloor+1 $$$ times, which is $$$ceil(T/c[i])$$$

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

Auto comment: topic has been updated by SuperMo (previous revision, new revision, compare).