#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |