Mridul323's blog

By Mridul323, history, 4 months ago, In English

Hello Codeforces,

Today I was trying to solve 1443C - The Delivery Dilemma from recent contest. In one of my solutions I used accumulate to find sum of all the elements in a vector but my solution failed on test case 4 then I tried general way of finding sum of all the elements and surprisingly this got accepted. To be honest I just couldn't figure out what was wrong in my previous solution. I tried searching internet but I could not find any drawback of accumulate so far.

Submission with Accumulate : 97509394 Submission without Accumulate : 97509418

I am really confused what could go wrong. Somebody please let me know if there is some mistake in my former submission and in which cases we should not use accumulate. Thanks in advance :)

 
 
 
 
  • Vote: I like it
  • +4
  • Vote: I do not like it

»
4 months ago, # |
  Vote: I like it +17 Vote: I do not like it

you need to do ll btot=accumulate(all(b),0LL); because accumulate in your submission will return int

  • »
    »
    4 months ago, # ^ |
      Vote: I like it +7 Vote: I do not like it

    Thank you so much bro. I was crazy for hours but here within 3 minutes I got my answer :)

»
4 months ago, # |
  Vote: I like it +15 Vote: I do not like it

Change accumulate(all(x), 0) to accumulate(all(x), 0LL).