Addition operation slower than STL::max() in C++ ?

Revision en2, by sixth_mancity_fan, 2024-06-07 12:09:34

I was doing the problem Bandit in a city. My submission used binary search to find the answer and check it. The problem arises for cases with answer 0 the code gave TLE on test 7. On using max() instead of + this code passed in 953 ms. I had to check for the corner case because the initial binary search code also gave TLE on test 7. I could not find anything to explain these. Is addition on long long integers slower than using max.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English sixth_mancity_fan 2024-06-07 12:09:34 1 Tiny change: ' of + this[code](htt' -> ' of + this [code](htt'
en1 English sixth_mancity_fan 2024-06-07 12:08:18 729 Initial revision (published)