Strange Runtime Error


#1

When i submit my solution in C++, for the input: 2 4 0 0 0 0 0 0 1 1
the compiler reports this Runtime Error:

*** Error in `./solution’: double free or corruption (out): 0x0000000000e8c150 ***
Aborted

Where as, on running the same case as custom input, it returns the expected solution just fine.
If any one can explain what is happening, the help is appreciated.


#2

Are you using initialized vector for storing? If not use it and try.