페이지

5527번: 전구 장식

https://www.acmicpc.net/problem/5527


#include<stdio.h>
#include<algorithm>
using namespace std;
int n, l[100002], lcnt;
int main() {
    int tmp, a;
    scanf("%d %d", &n, &tmp);
    l[++lcnt] = 1;
    for (int i = 1; i < n; i++) {
        scanf("%d", &a);
        if (a == tmp) lcnt++;
        l[lcnt]++;
        tmp = a;
    }
    int res = 0;
    for (int i = 1; i <= lcnt; i++)
        res = max(res, l[i - 1] + l[i] + l[i + 1]);
    printf("%d", res);
    return 0;
}

댓글 없음 :

댓글 쓰기