제출 #209989

#제출 시각아이디문제언어결과실행 시간메모리
209989AlainSuTelefoni (COCI17_telefoni)C++14
24 / 80
1098 ms1144 KiB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=4000000;
long long n,m,ans=0;
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,tmp;
	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;
}

컴파일 시 표준 에러 (stderr) 메시지

telefoni.cpp: In function 'void process()':
telefoni.cpp:23:3: warning: 'tmp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (tmp==now)
   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...