If you need a C solution then why are you including C++ headers? Anyway if you do it with C you need to learn how to dynamically allocate arrays with malloc. Sorry I can't help you with that. I'm sure that you can figure it out if you do a web search on malloc and array.
other than that I do not have to take care of memory redemption.
speed of the code is of my higher priority,
especially because I want to push N as large as the available memory allows
and I wonder that using deque has any speed disadvantage