답안 #485688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485688 2021-11-09T02:12:17 Z KazamaHoang Telefoni (COCI17_telefoni) C++14
80 / 80
25 ms 3244 KB
#include <bits/stdc++.h>

using namespace std;

int n, d, a[300005], s[300005], res = 0;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> d;
    for (int i = 1; i <= n; ++ i) {
        cin >> a[i];
        s[i] = s[i-1] + a[i];
    }
    for (int i = 1; i < n;) {
        if (a[i] == 1) {
            int mx = min(n, i + d);
            if (s[mx] - s[i]) {
                ++ i;
            } else {
                ++ res;
                a[mx] = 1;
                i = mx;
            }
        } else ++ i;
    }
    cout << res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 25 ms 3216 KB Output is correct
9 Correct 17 ms 3148 KB Output is correct
10 Correct 17 ms 3244 KB Output is correct