Submission #856078

#TimeUsernameProblemLanguageResultExecution timeMemory
856078vjudge1Telefoni (COCI17_telefoni)C++17
24 / 80
14 ms5212 KiB
#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+(!a[n]) << 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 timeMemoryGrader output
Fetching results...