Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int main()
- {
- int c,n,x,k=0,L=0;
- ifstream f("pinguini.in");
- f>>c>>n;
- if(c==1)
- while(n--)
- {
- f>>x;
- if(x==2)
- ++k;
- }
- if(c==2)
- while(n--)
- {
- f>>x;
- if(x==2)
- {
- ++k;
- while(x==2&&--n)
- f>>x;
- }
- }
- if(c==3)
- {
- while(n--)
- {
- f>>x;
- if(x==2)
- ++L;
- else
- if(L>k)
- k=L,L=0;
- else
- L=0;
- }
- if(L>k)
- k=L;
- }
- f.close();
- ofstream g("pinguini.out");
- g<<k;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement