Advertisement
Guest User

pinguini

a guest
Jan 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("pinguini.in");
  4. ofstream fout("pinguini.out");
  5. int n, i, v[10001], nr, c, k;
  6. int main()
  7. {
  8. fin >> c;
  9. fin >> n;
  10. for(i = 1; i <= n; ++i)
  11. {
  12. fin >> v[i];
  13. if(v[i] != 1) nr++;
  14. }
  15. if(c == 1)
  16. fout << nr << endl;
  17. nr = 0;
  18. for(i = 1; i <= n; ++i)
  19. {
  20. while(v[i] == 2)
  21. {
  22. i++;
  23. nr++;
  24. }
  25. if(nr)k++;
  26. nr = 0;
  27. }
  28. if(c == 2)
  29. fout << k << endl;
  30. nr = 0;
  31. k = 0;
  32. for(i = 1; i <= n; ++i)
  33. {
  34. while(v[i] == 2)
  35. {
  36. i++;
  37. nr++;
  38. }
  39. if(nr > k)
  40. {
  41. k = nr;
  42. }
  43. nr = 0;
  44. }
  45. if(c == 3)
  46. fout << k << endl;
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement