답안 #856088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856088 2023-10-02T16:31:42 Z vjudge1 Telefoni (COCI17_telefoni) C++17
0 / 80
1000 ms 4956 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];
	vi l(n+1);
	int lst = 1;
	F(i,n) {
		if (a[i]) lst = i;
		l[i] = lst;
	}
	int ans = 0;
	int ptr = n;
	while (ptr != 1) {
		if (l[ptr] < ptr-d) {
			ans++;
			ptr=max(1ll,ptr-d);
		}
		else ptr = l[ptr];
	}
	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 Execution timed out 1045 ms 344 KB Time limit exceeded
2 Execution timed out 1057 ms 348 KB Time limit exceeded
3 Execution timed out 1095 ms 348 KB Time limit exceeded
4 Execution timed out 1024 ms 344 KB Time limit exceeded
5 Execution timed out 1031 ms 344 KB Time limit exceeded
6 Execution timed out 1041 ms 348 KB Time limit exceeded
7 Execution timed out 1043 ms 348 KB Time limit exceeded
8 Execution timed out 1065 ms 4956 KB Time limit exceeded
9 Execution timed out 1036 ms 4952 KB Time limit exceeded
10 Execution timed out 1051 ms 4956 KB Time limit exceeded