Submission #1103493

#TimeUsernameProblemLanguageResultExecution timeMemory
1103493overwatch9Telefoni (COCI17_telefoni)C++17
80 / 80
46 ms3380 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; vector <int> nums(n); for (int i = 0; i < n; i++) cin >> nums[i]; vector <int> dp(n); dp[0] = 0; multiset <int> s; s.insert(0); for (int i = 1; i < n; i++) { dp[i] = *s.begin(); if (nums[i] == 0) dp[i]++; s.insert(dp[i]); if (i >= d) s.erase(s.find(dp[i-d])); } cout << dp[n-1] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...