Why it is showing segmentation fault

here is the code https://ide.codingblocks.com/s/225713
pls help

hello @pyash
you are applying greedy algorithm,it will not work on this problem becuase both the player are playing optimally.

refer this ->
image

thanks alot for the approach