ChenShou's blog

By ChenShou, history, 6 years ago, In English

Just now I finish the Codeforces Global Round 7 D2 by look at Tutorial, but I found that the different place of variable caused time cost different.

Here is the AC submit and TLE submit. The only difference is line 24 in ac submit and line 25 in TLE submit. Can anyone tell me something about it ? Thanks in advance.

  • Vote: I like it
  • +8
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

Honest question, what do you think the difference is between these two snippets?

void f(...) {
  int a[1024];
  ...
}

int main() {
  // Calls f a bunch of times
}

vs

int a[1024];
void f(...) {
  ...
}

int main() {
  // Calls f a bunch of times
}
Answer