Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <queue>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- vector<int> v(n);
- for(int i =0 ; i < n; i++) {
- cin >> v[i];
- }
- int consecutive = 0, result = 0;
- for(int i = 0; i < n; i++) {
- if(v[i] == 1) {
- consecutive++;
- }
- else {
- result = max(result, consecutive);
- consecutive = 0;
- }
- result = max(result, consecutive);
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement