Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
584 B
1
Indexable
Never
#include <iostream>

typedef long long ll;
using namespace std;

int a[100000];

int main(){
    freopen("FLOWERS.INP","r",stdin);
    freopen("FLOWERS.OUT","w",stdout);

    int n; cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    int l = 0, cnt = 0, h = a[0], max = 0;
    for(int i = 0; i < n; i++){
        ++l;
        if(a[i] == h) ++cnt;
        else{
            h = a[i];
            cnt = 1;
        }
        if(max < l) max = l;
        if(cnt == 3){
            cnt = 0; l = 2;
        }
    }
    cout << max << endl;

	return 0;
}
Leave a Comment