#include<bits/stdc++.h>
using namespace std;
const int MAXN=3500000;
long long n,m,ans=0,tmp;
bool a[MAXN];
void input()
{
cin>>n>>m;
long long p=1;
for (int i=1;i<=n;i++)
{
cin>>a[i];
if (a[i])
{
if (i-p>m)
{
ans+=(i-p)/m;
if ((i-p)%m>0) ans++;
ans--;
}
p=i;
}
}
}
void output()
{
cout<<ans;
}
int main()
{
input();
output();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
128 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
248 KB |
Output is correct |
8 |
Correct |
69 ms |
632 KB |
Output is correct |
9 |
Correct |
66 ms |
632 KB |
Output is correct |
10 |
Correct |
66 ms |
632 KB |
Output is correct |