ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1375. Bill Clevers

Memory troubles?
Posted by 2rf 7 Jun 2009 14:51
Well, i have problems with this problem)

When I send C++ solutions with such declaration: int d[100000] I receive Crash (access violation) at test 8 as it should be. But when I change it to int d[1000000] I receive Crash (stack overflow) at test 1.

Why? What is stack overflow? I use (or should I say don't use?) neither local variables nor recursion. Or maybe I just think so.

Memory limit here is 16 MB and size of int d[1000000] is 4 MB, right? Help me please!

UPD: I got AC by changing int d[1000000] to vector<int> d(1000000) but I still want to know answer to my question.

Edited by author 07.06.2009 14:57
Re: Memory troubles?
Posted by Sandro (USU) 7 Jun 2009 18:44
You have got Stack Overflow, because declared local array
d[1000000] inside of main() function. Just declare it before main() and you will not have problems with stack.
Re: Memory troubles?
Posted by 2rf 7 Jun 2009 22:42
Big thanks for such quick and helpful response!