aboutsummaryrefslogtreecommitdiff
path: root/LisaWorkbook.cpp
blob: 6d8532cc83b14f7fad755f1d7e3402915754f96a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  int pg = 1, res = 0;
  for (int i = 0; i < n; i++) {
    int np;
    cin >> np;
    for (int j = 1; j <= np ; j++) {
      if (j == pg) {
        res++;
      }
      if (j % k == 0 && j < np) {
        pg++;
      }
    }
    pg++;
  }
  cout << res << endl;
  return 0;
}