답안 #77106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77106 2018-09-21T12:16:50 Z 998244353 Telefoni (COCI17_telefoni) C++14
80 / 80
30 ms 3660 KB
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;

int n,d;

int main()
{
        scanf("%d %d",&n,&d);
        int a[n];
        for(int i=0;i<n;i++)
        {
                scanf("%d",&a[i]);
        }
        int temp=0,ans=0;
        for(int i=1;i<n;i++)
        {
                if(a[i]==1&&i-temp<=d)
                        temp=i;
                else
                {
                        if(i-temp>d)
                        {
                                temp=i-1;
                                ans+=1;
                                i-=1;
                        }
                }
        }
        printf("%d",ans);
        return 0;
}

Compilation message

telefoni.cpp: In function 'int main()':
telefoni.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&n,&d);
         ~~~~~^~~~~~~~~~~~~~~
telefoni.cpp:14:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%d",&a[i]);
                 ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Correct 2 ms 524 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 588 KB Output is correct
8 Correct 28 ms 2304 KB Output is correct
9 Correct 30 ms 3052 KB Output is correct
10 Correct 28 ms 3660 KB Output is correct