SIGSEGV error in Team Split -plz help

i think this error is due to this statement…
int s[3000000];
plz help how to allocate this size array…

1 Like

declare array outside main() function means make its globle array…
int s[3000000];
int main()
{
}
and use it

10 Likes

specially this query related to ongoing contest so please don’t ask…specially contest is for checking your skill not queries.
After contest you can ask any query

5 Likes

@maheiitr why it was giving error…when i used this declaration inside main…but not giving when i declared outside of main…

2 Likes

Global declaration reserves memory on the static memory which is large enough to not impose a memory problem. But local declarations reserves memory on the stack which it’s memory is limited. So you can’t declare an array as a local object with a large amount of memory otherwise you get out of the memory range which is known as a Stack Overflow

5 Likes

hope you understand …:slight_smile:

4 Likes

ya i got it…thanks

Do not try to use array in this prob as u need only the current and the previous value at any state
try to implement this logic it will save u lot of memory in future competition …

1 Like

I used global declaration for the array
but I’m still getting runtime error

http://www.codechef.com/viewsolution/3632978

You have taken the variables to be Integer data types. So when you are doing the following multiplication temptempa then the value exceeds the range of integers and hence become negative. So this would give a runtime error. So better take the data types to be Long Long Int.

declare your array globally with long long data type…dnt use unsigned long long,otherwise abs will gve WA

thanks!
that worked

@zargus thanks buddy… :slight_smile:

//