Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	N, A, B, C, D := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()

	x := (N + A - 1) / A * B
	y := (N + C - 1) / C * D

	var z int
	if x < y {
		z = x
	} else {
		z = y
	}

	fmt.Println(z)
}

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 <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

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

C++: #include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 1000000000;

int main(){
  int n, a, b, c, d;

  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

  int ans = INF;
  
  for(int i=0;;i++){
    ans = min(ans, i*b + max(0, (n-(i*a) + c-1)/c) * d);
    if(i*a >= n) break;
  }

  printf("%d\n",ans);

  return 0;
}

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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};



int main(){
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	cout << min(b*(n/a+(n%a?1:0)), d*(n/c+(n%c?1:0))) << endl;

	return 0;
}

C++: #included<bits/stdc++.h>
int main(){
    int N,A,B,C,D;
    double x,y;
    scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
    x=N/A;
    y=N/C;
    x=ceil(x);
    y=ceil(y);
    if (B*x <= D*y)
{printf(B*x);
else{printf(D*y);}



return 0;
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;

int n, a, b, c, d;

int main(){
  
  cin>>n>>a>>b>>c>>d;
  
  int v1 = n/a*b;
  if(n%a) v1+=b;
  
  int v2 = n/c*d;
  if(n%c) v1+=d;

  cout<<min(v1, v2)<<endl;
  
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,a,b,c,d,w,x,z,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	if(n%a==0){
		w=n/a;
	}
	else{
		w=n/a+1;
	}
	if(n%c==0){
		x=n/c;
	}
	else{
		x=n/c+1;
	}
	if(w*b<=x*d){
		printf("%d\n",w*b);
	}
	else{
		printf("%d\n",x*d);
	}
	return 0;
}

C++: #include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,b,c,d,x,y,xm,ym,mn;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;	
	if(n%a!=0)	x++;
	xm=x*b;
	y=n/c;
	if(n%c!=0)	y++;
	ym=y*d;
	mn=min(xm,ym);
	printf("%d\n",mn);
	return 0;
}

C++: n,a,b,c,d = map(int,input().split())
print(min(((n-1)//a+1)*b,((n-1)//c+1)*d))

C++: #include<bits/stdc++.h>
using namespace std;

int main(){

    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    int sum = 0;
    int sum1 = 0;
    for (int i=0;i<N;i=i+A){
       sum = sum+B;
    }
    for (int i=0;i<N;i=i+B){
       sum1 = sum1+D;
    }
    if(sum<=sum1){
      cout<<sum+B<<endl;
    } else {
      cout<<sum1+D<<endl;
    }
    return 0;
}

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


int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    string str;
    int N, A, B, C, D;
    int count = 0;
    getline(cin, str);
    stringstream ss;
        ss << str;
        ss >> N;
        ss >> A;
        ss >> B;
        ss >> C;
        ss >> D;
    
    int timesX, timesY;
    timesX = N / A + (N % A != 0);
    timesY = N / C + (N % C != 0);
    
    int sumX, sumY;
    sumX =  B * timesX;
    sumY =  D * timesY;
    
    int ans;
    if(sumX < sumY)
    ans = sumX;
    else
    ans = sumY;
    
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n, a, b, c, d;

	cin >> n >> a >> b >> c >> d;

	int x = ((n - 1) / a + 1) * b, y = ((n - 1) / c + 1) * d;

	if (x < y)
		cout << x << endl;
	else
		cout << y << 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;
    cout << min(((n + a - 1) / a) * b, ((n + c - 1) / c) * d) << '\n';
}

C++: 
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int ceil(int n, int d) {
	return (n + d - 1) / d;
}

int main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;

	int ans = min(ceil(n, a)*b, ceil(n, c)*d);

	cout << ans << endl;

	return 0;
}