Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	a, _ := nextInt()
	b, _ := nextInt()
	c, _ := nextInt()
	d, _ := nextInt()

	costX := b * int(math.Ceil(float64(n)/float64(a)))
	costY := d * int(math.Ceil(float64(n)/float64(c)))
	fmt.Println(min(costX, costY))
}

C++: #include<iostream>
using namespace std;
int main(){

	int N,A,B,C,D;
	
	cin >> N >> A >> B >> C >> D;
		
	int planA, planB;

	if(N % A == 0)
		planA = N / A * B;
	else
		planA = (N / A + 1) * B;

	if(N % C == 0)
		planB = N / C * D;
	else
		planB = (N / C + 1) * D;

	if(planA < planB)
		cout << planA << endl;
	else
		cout << planB << endl;

	/*
	int A,B,C,D,E;
	cin >> A >> B >> C >> D >> E;

	int answer;
	if(A < 0){
		answer = -A * C + D + B * E;
	}
	if(A > 0){
		answer = (B - A) * E;
	}
	cout << answer << endl;
	*/

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
  int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  int ta,tc;
  if(n%a) ta=n/a*b+b;
  else ta=n/a*b;
  if(n%c) tc=n/c*d+d;
  else tc=n/c*d;
  cout << (ta<tc?ta:tc) << endl;
  
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
main(){
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;

  int X = (n/a + (n%a>0?1:0))*b;
  int Y = (n/c + (n%c>0?1:0))*d;
  cout << min(X, Y) << endl;
}

C++: #include <iostream>
using namespace std;

int main() {
int N,A,B,C,D;
int Z,ZZ;
cin >> N >> A >> B >> C >> D;
if(N%A == 0){
	Z = N/A;
};
if(N%A != 0){
	Z = N/A + 1;
}
if(N%C == 0){
	ZZ = N/C;
};
if(N%C != 0){
	ZZ = N/C + 1;
};
if(Z*B <= ZZ*D){
	cout << Z*B << endl;
}
else if(Z*B > ZZ*D){
	cout << ZZ*D << endl;
}
return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, a, b, c, d,aa,bb,kin;
	cin >> n >> a >> b >> c >> d;
	aa = 0;
	kin = 0;
	while (aa < n) {
		aa = aa + a;
		kin =b + kin;
	}
	aa = kin;
	bb = 0;
	kin = 0;
	while (bb < n) {
		bb = bb + c;
		kin = d + kin;
	}
	bb = kin;
	cout << min(aa, bb) << endl;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define var auto
#define ll long long
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++) 
#define inp(a) int a; cin >> a;
#define inps(s) std::string s; cin >> s;
#define out(a) cout<<a<<endl;
#define pb(a) push_back((a))
#define endl "\n"
#define vi vector<int>


int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    int n = N - 1;
    int x = n / A + 1;
    int y = n / C + 1;

    // cerr << n << endl << x << endl << y;
    cout << min(x * B, y * D) << endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	cout << min((n +a-1)/a *b, (n +c-1)/c *d) << endl;
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main(void){
  int N,A,B,C,D,s,t;
    scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
    double x=ceil(N/A);
    double y=ceil(N/C);
    s=B*x;
    t=D*y;
    if (B*x <= D*y)
      {printf("%f\n",s);}
    else{printf("%f\n",t);}

return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n,a,b,c,d;
cin >> n >> a >> b >> c >> d;
if (n%a==0,n%c==0){
	if(n/a*b>=n/c*d){
		cout << n/a*b <<endl;
}
	else cout << n/c*d <<endl;
if (n%a==0,n%c!=0){
	if(n/a*b>=(n/c+1)*d){
		cout << n/a*b <<endl;
}
	else cout << (n/c+1)*d <<endl;
if (n%a!=0,n%c!=0){
	if((n/a+1)*b>=(n/c+1)*d){
		cout << (n/a+1)*b <<endl;
}
	else cout << (n/c+1)*d <<endl;
if (n%a!=0,n%c==0){
	if((n/a+1)*b>=n/c*d){
		cout << (n/a+1)*b <<endl;
}
	else cout << n/c*d <<endl;
}
}
}
}
return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  int NA, NC;
  NA = (N + A - 1) / A;
  NC = (N + C - 1) / C;
  int ans;
  if(NA*B <= NC*D){
    cout << NA*B << endl;
  }else{
    cout <<  NC*D << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int x = (n + a - 1) / a;
    int y = (n + c - 1) / c;
    x *= b;
    y *= d;
    cout << min(x, y) << endl;
}

C++: #include <iostream>
int main(){
 
    int n = 0,a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;
    std::cin >> n >> a >> b >> c >> d;
    
    e = (a-1+n)/a*b;
    f = (c-1+n)/c*d;
    
    if(e > f){
        
     std::cout << f << std::endl;
        
    }else{
     
        std::cout << e << std::endl;
        
    }
    
}

C++: #include <iostream>
using namespace std;

int main()
{
    int N, A, B, C, D, penX = 0, penY = 0, rateX = 0, rateY = 0;
    cin >> N >> A >> B >> C >> D;

    while (penX < N)
    {
        penX += A;
        rateX += B;
    }

    while (penY < N)
    {
        penY += C;
        rateY += D;
    }
    
    
    if (rateX > rateY)
    {
        cout << rateY <<endl;
    }else{
        cout << rateX <<endl;
    }
    

    return 0;
}

C++: #include <iostream>

int calc(int n, int nset, int fee) {
  return ((n / nset) + (n % nset > 0)) * fee;
}

int main() {
  int n, a, b, c, d;
  std::cin >> n >> a >> b >> c >> d;
  std::cout << std::min(calc(n, a, b), calc(n, c, d)) << std::endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  if(n%a==0) a=n/a;
  else a=n/a+1;
  if(n%c==0) c=n/c;
  else a=n/c+1;
  if(a*b>c*d) cout<<c*d<<endl;
  else cout<<a*b<<endl;
  return 0;
}

C++: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    int sum1=0,sum2=0,n1=n,n2=n;
    while(n1>0){
        n1-=a;
        sum1+=b;
    }
    while(n2>0){
        n2-=c;
        sum2+=d;
    }
    cout<<min(sum1,sum2)<<endl;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int f(int n, int a, int b){
    int t = n/a + (n%a!=0);
    return t*b;
}

signed main(void) {
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    cout << min(f(n,a,b),f(n,c,d)) << endl;

}