Advertisement
999ms

Untitled

Apr 12th, 2020
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using i32 = int32_t;
  4. using ui32 = uint32_t;
  5. using i64 = int64_t;
  6. using ui64 = uint64_t;
  7.  
  8. using namespace std;
  9.  
  10.  
  11. i32 main() {
  12.   ios_base::sync_with_stdio(false);
  13.   cin.tie(nullptr);
  14.   cout.tie(nullptr);
  15.   int x, n;
  16.   cin >> x >> n;
  17.   vector<int> arr(n);
  18.   for (int i = 0; i < n; i++) cin >> arr[i];
  19.   int ans = 0;
  20.   while (arr.size()) {
  21.     while (arr.size() && arr.back() == 0) arr.pop_back();
  22.     if (arr.size()) {
  23.       int cur = x;
  24.       while (cur-- && arr.size()) arr.pop_back();
  25.       ans++;
  26.     }
  27.   }
  28.   cout << ans << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement