1 solutions

  • 0
    @ 2026-11-13 19:57:16

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n;
        cin >> n;
    
        vector<int> dp(n + 1, 1e9);
        dp[0] = 0;
    
        for (int i = 1; i <= n; i++) {
            if (i >= 1)  dp[i] = min(dp[i], dp[i - 1] + 1);
            if (i >= 5)  dp[i] = min(dp[i], dp[i - 5] + 1);
            if (i >= 11) dp[i] = min(dp[i], dp[i - 11] + 1);
        }
    
        cout << dp[n] << endl;
        return 0;
    }
    
    • 1

    Information

    ID
    101
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By