Submission #521128

#TimeUsernameProblemLanguageResultExecution timeMemory
521128penguin133Telefoni (COCI17_telefoni)C++14
80 / 80
42 ms2032 KiB
#include <bits/stdc++.h> using namespace std; int A[300005]; int main(){ int n,d;cin >> n >> d; for(int i=1;i<=n;i++)cin >> A[i]; int maxi = 1, cnt = 0; for(int i=2;i<=n;i++){ if(i > maxi + d)maxi = i - 1, cnt++; if(A[i])maxi = i; } cout << cnt; }
#Verdict Execution timeMemoryGrader output
Fetching results...