Advertisement
a53

pinguini

a53
Jan 29th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int c,n,x,k=0,L=0;
  7. ifstream f("pinguini.in");
  8. f>>c>>n;
  9. if(c==1)
  10. while(n--)
  11. {
  12. f>>x;
  13. if(x==2)
  14. ++k;
  15. }
  16. if(c==2)
  17. while(n--)
  18. {
  19. f>>x;
  20. if(x==2)
  21. {
  22. ++k;
  23. while(x==2&&--n)
  24. f>>x;
  25. }
  26. }
  27. if(c==3)
  28. {
  29. while(n--)
  30. {
  31. f>>x;
  32. if(x==2)
  33. ++L;
  34. else
  35. if(L>k)
  36. k=L,L=0;
  37. else
  38. L=0;
  39. }
  40. if(L>k)
  41. k=L;
  42. }
  43. f.close();
  44. ofstream g("pinguini.out");
  45. g<<k;
  46. g.close();
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement