Submission #1184775

#TimeUsernameProblemLanguageResultExecution timeMemory
118477512345678Roses (BOI20_roses)C++20
100 / 100
1 ms400 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll n, a, b, c, d, ans=1e18;

ll divide(ll x, ll y)
{
    if ((x%y)==0) return x/y;
    return x/y+1;
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>a>>b>>c>>d;
    for (int i=0; i<=100000; i++) if (a*i<=n) ans=min(ans, b*i+divide(n-a*i, c)*d);
    for (int i=0; i<=100000; i++) if (c*i<=n) ans=min(ans, d*i+divide(n-c*i, a)*b);
    cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...