제출 #522857

#제출 시각아이디문제언어결과실행 시간메모리
522857emptypringlescanTelefoni (COCI17_telefoni)C++14
80 / 80
13 ms2044 KiB
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	int arr[n];
	for(int i=0; i<n; i++) cin >> arr[i];
	int next=0,ans=0;
	for(int i=0; i<n; i++){
		if(arr[i]==1){
			next=i+m;
			continue;
		}
		if(i==next){
			ans++;
			next=i+m;
		}
	}
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...