How can the same code gap be so great?

Revision en2, by justarandomstring, 2017-09-19 06:56:21

It wasn't the first or second time I had this problem, so I couldn't help asking what was going on.

Today, I had a strange problem when I submitted this question 600E - Lomsat gelral

First, I submitted this code:

The full code is here: My TLE code

// ...Omitted...
long long Sum, v[MAXN], ans[MAXN];
// ...Omitted...

and got TLE(used more than 2000ms).

After a long inspection, I didn't find any problems, so I wrote it again. The new code is:

The full code is here: My AC code

// ...Omitted...
long long ans[MAXN], v[MAXN], Sum;
// ...Omitted...

ans got AC(only used 140ms).

The omission of the two code is exactly the same, and the result is too different!

I wonder what really happened.


Tags c++


  Rev. Lang. By When Δ Comment
en2 English justarandomstring 2017-09-19 06:56:21 38
en1 English justarandomstring 2017-09-19 06:54:50 867 Initial revision (published)