Untitled
unknown
plain_text
a year ago
584 B
4
Indexable
#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; }
Editor is loading...
Leave a Comment