Hi!
I have two really similar submissions to problem (https://codeforces.net/contest/1266/problem/E)
https://codeforces.net/contest/1266/submission/67209030 (**WA version**)
https://codeforces.net/contest/1266/submission/67209163 (**AC version**)
The WA version has the following line:
long long ans = accumulate( a.begin(), a.end(), 0, [] (long long a, long long b) { return a + b; } );
With this simple change on this specific line I got it accepted.
long long ans = accumulate( a.begin(), a.end(), 0ll, [] (long long a, long long b) { return a + b; } );
Why the zero of the WA version does not seem to be converted to long long?
Auto comment: topic has been updated by FThiesen (previous revision, new revision, compare).
Cuz the type of the return value of accumulate() is the type of the init (third argument) , and the type of integer literal 0 is
int
.Thank you for the simple explanation! I missed this information when I checked out cppreference..
Accumulate(a, b, c, func) work something like this: