Double vs long long 2D array speed difference

I was using a 2D array of long long in my code and getting TLE. But, when I use double instead of long long, my code is accepted.

Anyone knows the reason for this?

can u share your submission

Long long is extremely slow. Any type of algorithm that involves lots of computations with numbers will run significantly slower with long long’s than with doubles or ints32’s.

You should understand when long long is necessary and use it just in those cases (I’m a person who likes to use long long’s for every problem, just because I’ve become a bit skeptical, but that costs me a quick AC sometimes).

TL;DR Long long performs very similar to int/double in most cases, but lots of computations tend to slow your program down by couple o tens or even hundreds of milliseconds when using long long.

Hope this helps! :smiley:

1 Like