Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  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(p != n - 1)
  13. {
  14. if(t[q] == 0)
  15. d++;
  16. else
  17. c++;
  18. if(d == m)
  19. {
  20. mini = min(mini, c);
  21. for(t[p] != 0; p++;)
  22. {
  23. if(t[p] == 0)
  24. d--;
  25. else
  26. c--;
  27. mini--;
  28. }
  29. }
  30. q++;
  31. }
  32. if(mini == n + 1)
  33. cout << "NIE";
  34. else
  35. cout << mini;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement