답안 #856066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856066 2023-10-02T16:14:11 Z vjudge1 Telefoni (COCI17_telefoni) C++17
80 / 80
12 ms 860 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 200005
using namespace std;





void solve(){
    int n,d; cin >> n >> d;
    int ans=0, cur=d+1;
    for(int i=1; i<=n; i++){
        int a; cin >> a;
        if(a==1){
            cur = i+d;
        }
        else if(i==cur){
            ans++;
            cur = i+d;
        }
    }
    cout << ans << endl;
}



signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif

    int t=1;
    //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 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 Correct 12 ms 824 KB Output is correct
9 Correct 12 ms 856 KB Output is correct
10 Correct 11 ms 860 KB Output is correct