I was solving this.
I encountered a problem while using std::accumulate
.
I noticed that accumulate(v.begin(), v.end(), 0L)
behaves differently in sublimText/Ideone and Codeforces.
for example,
int main() {
vector<long long> v{1,-1000000000,1,-1000000000,1,-1000000000};
long long sum = accumulate(v.begin(), v.end(), 0L);
cout<<sum;
}
in sublimeText or Ideone: prints -2999999997
and in Codeforces prints 1294967299
.
however, when 0L is changed to 0LL in accumulate function, both sublime text and CF returns the right sum (-2999999997)
is this expected? can someone help me understand this weird behavior?