BUPT-homework/semester1/pset9/8-longest.c

32 lines
468 B
C
Raw Permalink Normal View History

2021-11-25 17:04:19 +08:00
#include <stdio.h>
#define MAXNUM 1000
int main(void) {
int n;
scanf("%d", &n);
int maxlen[MAXNUM] = {};
int count = 0;
int prev, head;
scanf("%d", &prev);
for (int i = 1; i < n; i++) {
scanf("%d", &head);
if (head == prev) {
maxlen[count]++;
} else {
prev = head;
count++;
}
}
int max = 1;
for (int i = count; i >= 0; i--) {
if (maxlen[i] + 1 > max) {
max = maxlen[i] + 1;
}
}
printf("%d", max);
return 0;
}