Submission #1132649

#TimeUsernameProblemLanguageResultExecution timeMemory
1132649DangKhoizzzzTelefoni (COCI17_telefoni)C++20
80 / 80
9 ms2736 KiB
#include <bits/stdc++.h> #include <bits/stdc++.h> #define int long long using namespace std; const int maxn = 1e6 + 7; int n , d , a[maxn]; vector <int> pos; void solve() { cin >> n >> d; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) { if(a[i]) pos.push_back(i); } int ans = 0; for(int i = 1; i < pos.size(); i++) { ans += (pos[i] - pos[i-1] - 1)/d; } cout << ans << '\n'; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...