답안 #856073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856073 2023-10-02T16:18:38 Z vjudge1 Telefoni (COCI17_telefoni) C++17
24 / 80
14 ms 5212 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define all(x) x.begin()+1,x.end()
const int N = 4e5+1;


void solve() {
	int n,d;
	cin >> n >> d;
	vi a(n+1);
	F(i,n) cin >> a[i];
	int ans = 0;
	int R = 1;
	int ptr = 1;
	while (ptr < n) {
		//cout << ptr sp R << endl;
		for (;ptr<=R;ptr++) if (a[ptr]) R = ptr+d;
		if (ptr <= n) {
			ans++;
			R = ptr+d;
		}
	}
	cout << ans << endl;
}     	
                 
                 
                 
                 
                 
                 
                 
                 
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}

# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Runtime error 14 ms 5212 KB Execution killed with signal 11
9 Incorrect 13 ms 2808 KB Output isn't correct
10 Runtime error 14 ms 5120 KB Execution killed with signal 11