제출 #1352786

#제출 시각아이디문제언어결과실행 시간메모리
1352786ErJLawn Mower (CEOI25_lawnmower)C++20
25 / 100
454 ms1114112 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define pp pair<ll, ll>
#define vp vector<pp>
#define inf 1000000000000000000
#define mod 1000000007

ll mow(int n, int c, int b, vector<int> &a, vector<int> &v){
    vvi dp(n + 1, vi(c, inf));
    dp[0][0] = 0;
    for(int i = 0; i + 1 < dp.size(); i++){
        for(int j = 1; j < dp[i].size(); j++){
            dp[i][0] = min(dp[i][0], dp[i][j] + b);
        }
        for(int j = 0; j < dp[i].size(); j++){
            ll cnt = v[i];
            ll tim = a[i];
            ll capacity = c - j;
            if(cnt < capacity){
                dp[i + 1][j + cnt] = min(dp[i + 1][j], dp[i][j] + tim);
                continue;
            }
            ll cntB = 1;
            ll x = tim;
            cnt -= capacity;
            ll cntA = (cnt + c - 1)/c;
            x += cntA * tim;
            ll cntA2 = cnt/c;
            cnt -= c * cntA2;
            cntB += cntA2;

            x += cntB * b;
            dp[i + 1][cnt] = min(dp[i + 1][cnt], dp[i][j] + x);
        }
    }
    for(int j = 1; j < dp[n].size(); j++){
        dp[n][0] = min(dp[n][0], dp[n][j] + b);
    }
    return dp.back()[0];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...