Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! ![]()
Edit:
int a[5000]
N can be up to 10000.
Edit2:
if(a[i]<a[i-1])
When this is called, i == n, so even if a has space for 10000 elements, this would still be an out-of-bounds access when N=10000.