# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209991 | AlainSu | Telefoni (COCI17_telefoni) | C++14 | 1100 ms | 632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |