제출 #1353395

#제출 시각아이디문제언어결과실행 시간메모리
1353395Alex1298Lawn Mower (CEOI25_lawnmower)C++20
25 / 100
2094 ms2204 KiB
#include <iostream>
#include <vector>

using namespace std;

int n, c, b;
int timp[200005];
int cant[200005];
long long dp[200005];
long long INF = (1LL << 60);

long long mow(int N, int C, int B, std::vector<int> &A, std::vector<int> &V)
{
    n = N;
    c = C;
    b = B;
    for(int i = 0; i<n; i++)
    {
        timp[i + 1] = A[i];
        cant[i + 1] = V[i];
    }

    dp[n + 1] = 0;
    for(int i = n; i>=1; i--)
    {
        long long timp_add = 0;
        dp[i] = INF;
        int sum = 0;

        for(int j = i; j<=n; j++)
        {
            if(sum == c)
            {
                break;
                timp_add += b;
                sum = 0;
            }

            if(cant[j] <= c - sum)
            {
                timp_add += timp[j];
                sum += cant[j];
            }
            else
            {
                int temp = cant[j] - (c - sum);
                timp_add += timp[j] + b;
                sum = 0;

                int cnt = (temp + c - 1) / c;
                timp_add += 1LL * cnt * timp[j];
                timp_add += 1LL * (cnt - 1) * b;

                if(temp % c == 0)
                {
                    sum = c;
                }
                else
                {
                    sum = temp % c;
                }
            }

            dp[i] = min(dp[i], timp_add + b + dp[j + 1]);
        }
    }

    return dp[1];
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…