제출 #86418

#제출 시각아이디문제언어결과실행 시간메모리
86418MaHaMBa_25Telefoni (COCI17_telefoni)C++14
80 / 80
30 ms2504 KiB
#include <bits/stdc++.h>
#define GLHF ios_base::sync_with_stdio(0); cin.tie(), cout.tie();
#define GGWP return 0;
#define ALTF4 exit(0)
#define GCWS/*Good Contest, Well Solved*/ ALTF4
#define ull unsigned long long
#define ll long long
#define ld long double
#define fxr1(x) for(int I = 0; I < x; ++I)
#define fxr(x) for(int I = 0; I <= x; ++I)
 
using namespace std;
 
int n, d, ans, cnt;
bool a[300001];
 
int main()
{
	GLHF
	cin >> n >> d;
	for ( int I = 0; I < n; ++I )	
	{
		cin >> a[I];
		if ( a[I] == 0 )
			++cnt;
		else
			cnt = 0;
		if ( cnt == d )
		{
			++ans;
			a[I] = 1;
			cnt -= d;
		}
	}
	cnt = 1;
	for ( int I = 0; I < n - 2; ++I )
	{
		if ( a[I] == 0 )
		{
			++cnt;
		}
	}
	cout << ans << endl;
	GGWP
}
 
//clang++ -v -std=c++11 finish fishing the fish.people
#Verdict Execution timeMemoryGrader output
Fetching results...