Some tasks on Codeforces result in a "TLE" (Time Limit Exceeded) when using a long long
for some variables, while changing them to int
results in an "Accepted".
How does that issue affect the code? How do compilers deal with it? Why is the code faster when using int
?
This depends heavily on the platform. Here are two instances of where using a long long
may slow down your code:
long long
is 64 bit and int
is 32 bit) then there is more work involved in performing operations such as addition. int
to a long long
can have a large impact because the data is twice as large. Pulling data from disk or ram to the CPU cache is expensive, and if the datatype is twice as big, the CPU must request data more often.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.