SHARE
TWEET

Untitled

a guest Oct 20th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, m, p = 0, q = 0, c = 0, d = 0;
  4. int t[1000019];
  5. int main()
  6. {
  7.     ios_base::sync_with_stdio(0);
  8.     cin >> n >> m;
  9.     int mini = n + 1;
  10.     for(int i = 0; i < n; i++)
  11.         cin >> t[i];
  12.     while(q != n - 1)
  13.     {
  14.         if(t[q] == 0)
  15.             d++;
  16.         else
  17.             c++;
  18.         while(d == m)
  19.         {
  20.                 p++;
  21.                 if(t[p] == 0)
  22.                 d--;
  23.                 else
  24.                 c--;
  25.                 mini = min(mini, c);
  26.  
  27.         }
  28.  
  29.         q++;
  30.     }
  31.     if(mini == n + 1)
  32.         cout << "NIE";
  33.     else
  34.         cout << mini;
  35. }
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