답안 #75048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75048 2018-09-08T06:44:00 Z charlies_moo Telefoni (COCI17_telefoni) C++17
80 / 80
60 ms 672 KB
#include <iostream>

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    int lt;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            lt = i;
        } else if (i - lt == d) {
            lt = i;
            c++;
        }
    }

    cout << c << endl;

    return 0;
}

Compilation message

telefoni.cpp: In function 'int main()':
telefoni.cpp:15:22: warning: 'lt' may be used uninitialized in this function [-Wmaybe-uninitialized]
         } else if (i - lt == d) {
                    ~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 672 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 57 ms 672 KB Output is correct
9 Correct 57 ms 672 KB Output is correct
10 Correct 60 ms 672 KB Output is correct