SHARE
TWEET

Untitled

a guest Dec 13th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. ifstream fin ("pinguini.in");
  6. ofstream fout ("pinguini.out");
  7. int v[10001], n, k;
  8. int c;
  9.  
  10. int main()
  11. {
  12.     fin >> c >> n;
  13.     if (c == 1)
  14.     {
  15.         for (int i = 1; i<=n; i++)
  16.             fin >> v[i];
  17.         for (int i = 1; i<=n; i++)
  18.             if (v[i] == 2)
  19.                 k++;
  20.         fout << k;
  21.     }
  22.     if (c == 2)
  23.     {
  24.         for (int i = 1; i<=n; i++)
  25.             fin >> v[i];
  26.         for (int i = 1; i<n; i++)
  27.             if (v[i] == 2 and v[i+1] == 1)
  28.                 k++;
  29.         if (v[n] == 2)
  30.             k++;
  31.         fout << k;
  32.     }
  33.     if (c == 3)
  34.     {
  35.         int kmax = 0;
  36.         for (int i = 1; i<=n; i++)
  37.             fin >> v[i];
  38.         for (int i = 1; i<=n; i++)
  39.             if (v[i] == 2)
  40.             {
  41.                 k++;
  42.                 if (k > kmax)
  43.                     kmax = k;
  44.             }
  45.             else
  46.             k = 0;
  47.         fout << kmax;
  48.  
  49.     }
  50.     return 0;
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top