I was doing <a href='/contest/1512/problem/D' title='Codeforces Round 713 (Div. 3)'>1512D - Corrupted Array problem and i noticed a strange thing.
In order to calculate sum of the vector elements , I used the accumulate function available in STL
typedef long long ll;
#define int ll
//the sum variable and elements in vector becomes long long type
int sum=0;
sum=accumulate(v.begin(),v.end(),0);
This basically gives the wrong answer .
But
#define int ll
int sum=0;
sum=accumulate(v.begin(),v.end(),sum);
or
sum=accumulate(v.begin(),v.end(),0LL);
gets accepted.
Why is this happening ?
All these days, I thought it is just an initial value that we give to the accumulate function (the last argument), but it is not just an initial value and plays a big role in the outcome of the sum.
I am telling it isn't just a value because
ll sum=10;
sum+=20;
Now it wouldn't matter if 20 is given in LL or not , but here 0 gives WA but 0LL is accepted.