#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;
for (int i=1;i<=n;i++)
cin>>a[i];
}
void process()
{
int now=1,maxr=m+1;
while (maxr<n)
{
for (int i=maxr;i>=now;i--)
if (a[i])
{
tmp=i;
break;
}
if (tmp==now)
{
ans++;
now=maxr;
}
else
{
now=tmp;
}
maxr=now+m;
}
}
void output()
{
cout<<ans;
}
int main()
{
input();
process();
output();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Execution timed out |
1093 ms |
256 KB |
Time limit exceeded |
5 |
Execution timed out |
1096 ms |
256 KB |
Time limit exceeded |
6 |
Execution timed out |
1064 ms |
256 KB |
Time limit exceeded |
7 |
Execution timed out |
1100 ms |
256 KB |
Time limit exceeded |
8 |
Execution timed out |
1094 ms |
632 KB |
Time limit exceeded |
9 |
Execution timed out |
1097 ms |
632 KB |
Time limit exceeded |
10 |
Execution timed out |
1097 ms |
632 KB |
Time limit exceeded |