Now, don’t get me wrong. It’s a simple question, but
seeing the AC count on my UVa account increase is blissful, and
I wanted to find faster ways to solve it.
My first submission is basically the following (forgot to optimize iostream though):
The execution time was 0.280 seconds, which wasn’t so great. Since the maximum input was 2^32 (literally UINT_MAX + 1 on most platforms), using long long on it seemed to be a waste, especially when I didn’t know if the server was 32-bit or 64-bit.
Anyway, I wrote the following:
And got a time of 0.020 seconds. Now, I wondered what results I’ll get if I went back to long long, keeping the iostream optimizations.
And the time was STILL 0.020. Turned out that it didn’t make a big difference.
Anyway, I might dig out the extremely optimized version of input and atoi that I wrote some time ago, and give that a try in the future.