답안 #1087051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087051 2024-09-12T06:53:46 Z toast12 Telefoni (COCI17_telefoni) C++14
64 / 80
26 ms 3412 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    vector<int> telephones(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> telephones[i];
    }
    int ans = 0;
    int last = 1;
    int i = last;
    while (i < n) {
        int x = last;
        for (int j = i; j <= i + d; j++) {
            if (telephones[j])
                x = j;
        }
        if (x == last) {
            ans++;
            last += d;
            i = last;
        }
        else {
            i = x;
            last = x;
        }
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Runtime error 26 ms 3400 KB Execution killed with signal 11
9 Correct 25 ms 2108 KB Output is correct
10 Runtime error 26 ms 3412 KB Execution killed with signal 11