Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int n, valp, m=0;
- bool pint=true;
- cin >> n;
- int p[n], e[n];
- cin >> p[0];
- for(int i=1; i<n; i++){
- cin >> p[i];
- if(p[i]+p[i-1]<1000) e[i]=1;
- else e[i]=0;
- }
- if(p[n-1]+p[0]<1000) e[0]=1;
- else e[0]=0;
- int s=0;
- for(int i=1; i<n; i++){
- if(e[i]==1){
- s=s+1;
- }
- else{
- if(pint){
- valp=s;
- pint=false;
- }
- s=0;
- }
- if(m<s) m=s;
- }
- if(e[0]==1) if(m<1+valp+s)m=1+valp+s;
- cout << m;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement