답안 #147578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147578 2019-08-30T07:20:39 Z Ruxandra985 Telefoni (COCI17_telefoni) C++14
80 / 80
28 ms 1528 KB
#include <cstdio>

using namespace std;
int v[300010];
int main()
{
    int n,d,i,latest,add=0;
    scanf ("%d%d",&n,&d);
    for (i=1;i<=n;i++)
        scanf ("%d",&v[i]);
    latest = 1;
    for (i=2;i<=n;i++){
        if ( i - latest == d ){
            if (!v[i]){
                add++;
                latest = i;
            }
        }
        if (v[i])
            latest = i;
    }
    printf ("%d",add);
    return 0;
}

Compilation message

telefoni.cpp: In function 'int main()':
telefoni.cpp:8:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d%d",&n,&d);
     ~~~~~~^~~~~~~~~~~~~~
telefoni.cpp:10:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d",&v[i]);
         ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 276 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 424 KB Output is correct
8 Correct 28 ms 1528 KB Output is correct
9 Correct 28 ms 1400 KB Output is correct
10 Correct 28 ms 1528 KB Output is correct