#include <stdio.h>
int main(){
int i, j, d, n, l, c = 0,a[5000],f[5000]={0};
scanf("%d", &n);
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
for(i = 1; i < n; i++) {
if(f[i]==0) {
f[i] = 1;
d = a[i] - 1;
l = a[i];
c++;
for(j = i + 1; j < n; j++) {
if(l + d == a[j]) {
f[j] = 1;
l = a[j];
}
}
}
}
printf("%d\n", c);
return 0;
}
No comments:
Post a Comment