Submission #891712

# Submission time Handle Problem Language Result Execution time Memory
891712 2023-12-23T17:12:03 Z ind1v Telefoni (COCI17_telefoni) C++11
80 / 80
13 ms 1308 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

const int N = 3e5 + 4;

bool a[N];
int n, d, p, c;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> d;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (i == 1) {
      p = i + d;
    } else {
      if (a[i] == 1) {
        if (p < i) {
          ++c;
        }
        p = i + d;
      } else {
        if (p < i) {
          p += d;
          ++c;
        }
      }
    }
  }
  cout << c;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 13 ms 1304 KB Output is correct
9 Correct 13 ms 1084 KB Output is correct
10 Correct 13 ms 1308 KB Output is correct