# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
856088 | vjudge1 | Telefoni (COCI17_telefoni) | C++17 | 1095 ms | 4956 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |