-1
void miniMaxSum(vector<int> arr) {
    sort(arr.begin(),arr.end());

    long long int m=accumulate(arr.begin(),arr.end(),0);
    
    cout<<m;
}

Input array is 396285104 573261094 759641832 819230764 364801279 the answer it gives is -1381747223 how i dont know

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
  • 2
    A frequent mistake with `accumulate` is that the type of the accumulation is determined by the initial value, not by the vector elements. And `0` is an `int`... – molbdnilo Aug 18 '23 at 07:26
  • 1
    the vectos elements are `int`, the initial value `0` is `int`, there is no way `accumulate` can know that you want a `long long int`. Use `0LL` – 463035818_is_not_an_ai Aug 18 '23 at 07:27

0 Answers0