답안 #237796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237796 2020-06-08T19:08:25 Z marlicu Telefoni (COCI17_telefoni) C++14
80 / 80
25 ms 1280 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 3e5 + 5;

int n, d;
bool telefon[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        cin >> telefon[i];
    }

    int zadnji = 0;
    int dodano = 0;
    for (int i = 1; i < n; i++) {
        if (telefon[i]) zadnji = i;
        if (!telefon[i] && (i - zadnji) >= d) {
            dodano++;
            zadnji = i;
        }
    }

    cout << dodano << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 24 ms 1272 KB Output is correct
9 Correct 23 ms 1280 KB Output is correct
10 Correct 25 ms 1280 KB Output is correct