Hello, I have problems with problem SMPSEQ7 - namely, as for my code works perfectly fine on my computer, it fails on judge (wrong anwser) and I have no idea why. Every example works on ideone. Can you help me figuring out what is wrong with it?
Here's my code
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int check(int *S, int m) {
int i, first = 1;
for (i = 1; i < m; ++i) {
if (first) if (!(S[i] > S[i + 1])) first = 0;
else if (!(S[i] < S[i + 1])) return 1;
}
return 0;
}
int main(void)
{
int i, n, *S;
scanf("%d", &n);
++n;
S = (int*)malloc(n*sizeof(*S));
for (i = 1; i < n; ++i) scanf("%d", &S[i]);
if (check(S, n)) printf("%s", "Yes");
else printf("%s", "No");
return 0;
}
And here's the problem: http://www.spoj.com/problems/SMPSEQ7/
Regards