답안 #856076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856076 2023-10-02T16:20:03 Z vjudge1 Telefoni (COCI17_telefoni) C++17
24 / 80
22 ms 5216 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 (R<n) {
			ans++;
			R++;
			a[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 Correct 1 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 1 ms 348 KB Output isn't correct
8 Runtime error 22 ms 5216 KB Execution killed with signal 11
9 Incorrect 13 ms 2792 KB Output isn't correct
10 Runtime error 15 ms 5212 KB Execution killed with signal 11