제출 #1342346

#제출 시각아이디문제언어결과실행 시간메모리
1342346Jakub_WozniakTycho (BOI23_tycho)C++20
27 / 100
2095 ms2076 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll oo = (1e+18);
const int maxn = 100009;
ll dpx[maxn];
ll Ts[maxn];
ll T[maxn];

ll Rt[maxn];
ll Sg = 0 , S = 0;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n , b , d , p;
    cin >> b >> p >> d >> n;
    n++;
    T[0] = 0;
    T[n] = b;
    for(int i = 1; i < n ; i++)
    {
        cin >> T[i];
    }

    dpx[n] = oo;
    for(int i = n-1 ; i >= 0 ; i--)
    {
        ll A = T[i+1]-T[i];
        S += A;
        dpx[i] = S+S/p*d;
        if(S%p == 0)dpx[i] -= d;
        
        ll Fie = 0;
        ll Sg = S/p*d + S - S%p;
        for(int j = i+1 ; j <= n ; j++)
        {
            Fie = 0;
            if(Ts[j]%p >= S%p)
            {
                Fie = -d;
            }
            else
            {
                Fie = p;
            }
            dpx[i] = min(dpx[i] , Sg +  Rt[j]  + Fie);
        }
        Ts[i] = S;
        Rt[i] = dpx[i] - (Ts[i]/p*d) - Ts[i] + Ts[i]%p;
    }

    cout << dpx[0] << '\n';
    return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...