Submission #1103493

# Submission time Handle Problem Language Result Execution time Memory
1103493 2024-10-21T04:15:24 Z overwatch9 Telefoni (COCI17_telefoni) C++17
80 / 80
46 ms 3380 KB
#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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 46 ms 3372 KB Output is correct
9 Correct 38 ms 3156 KB Output is correct
10 Correct 46 ms 3380 KB Output is correct