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

Автор Eyes_on_me, история, 2 года назад, По-английски

I used accumulate for calculating the sum of elements of the array(which got hacked) however simply calculating the sum via iteration gives the correct result.

Am i missing something or is there any problem with using this "accumulate" thing.

Accepted — (https://mirror.codeforces.com/contest/1985/submission/265437274) ,(https://mirror.codeforces.com/contest/1985/submission/265439252)

Hacked — (https://mirror.codeforces.com/contest/1985/submission/265303752)

update — this idea of using all the attacks at once (at 1st second) requires to calculate the sum of the array ,but this sum can overflow (long long is insufficient). Better idea is to use the ceil division in the check function like this :

tot += ((have + cool[i] — 1)/cool[i]) * attack[i]; Hacker of the above solution helped me figure this out. Thanks a lot sammyuri sir.

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

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

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

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +12 Проголосовать: не нравится

It will overflow due to 0 not being a long long, You should use

long long sum = accumulate(array.begin(), array.end(), 0ll); 

instead of

long long sum = accumulate(array.begin(), array.end(), 0);
»
2 года назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

You have to use it like this:

long long int sum = accumulate(arr.begin(), arr.end(), 0LL);

You missed the 0LL.

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

in the binary search part of this question why the submission using the upper limit as greater than 1e13 got hacked??

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

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