답안 #209989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209989 2020-03-16T08:04:45 Z AlainSu Telefoni (COCI17_telefoni) C++14
24 / 80
1000 ms 1144 KB
#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;
}

Compilation message

telefoni.cpp: In function 'void process()':
telefoni.cpp:23:3: warning: 'tmp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (tmp==now)
   ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Execution timed out 1098 ms 248 KB Time limit exceeded
5 Execution timed out 1097 ms 376 KB Time limit exceeded
6 Execution timed out 1098 ms 376 KB Time limit exceeded
7 Execution timed out 1095 ms 376 KB Time limit exceeded
8 Execution timed out 1080 ms 1144 KB Time limit exceeded
9 Execution timed out 1088 ms 1144 KB Time limit exceeded
10 Execution timed out 1097 ms 1144 KB Time limit exceeded