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<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;
}

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

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	cout << min((A - 1 + N) / A * B, (C - 1 + N) / C * D) << endl;
}

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

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

using namespace std;

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

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

	int p = 0,q = 0;

	for (int i = 0; i < n + 1; i++)
	{
		if (i * a >= n)
		{
			p = b * i;
			break;
		}
	}
	for (int i = 0; i < n + 1; i++)
	{
		if (i * c >= n)
		{
			q = d * i;
			break;
		}
	}

	cout << min(p,q) << endl;
}

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


int main(){
  int min;
  int N,A,B,C,D;

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

  bool first_f = false;
  int kane = 0;
  int honsu = 0,counter = 0;
  for(int i=0; i<N/A + 1; ++i){
    for(int k=0; k<N/C + 1; ++k){
      honsu += A;
      kane += B;
      ++counter;
      if(honsu >= N){
	if(!first_f){
	  first_f = true;

	  min = kane;
	}else{
	  if(min > kane){
	    min = kane;

	    break;
	  }
	}
      }
    }
    honsu -= counter * A;
    honsu += C;
    kane -= counter * B;
    kane += D;
    counter = 0;
  }

  cout << kane / 2 << endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
#define INF 100000000
int main(){
  int N,pen,kati;
  cin >> N ;
  int ans = INF;
  for(int i=0;i<2;i++){
    cin >> pen >> kati;
    int a = N / pen;
    if(N%pen>=1) a++;
    ans = min(ans,a*kati);
  }
  cout << ans << endl;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d,i=1,x,k,k1,k2,j=1,I,J;
    cin>>n>>a>>b>>c>>d;  
    if(n%a==0){
      k1=n/a;
    }
    else {
       k1=n/a+1;
    }
    if(n%c==0){
      k2=n/c;
    }
    else{
      k2=n/c+1;
    }
  if(k1*b==k2*d){
    cout<<k1*b<<endl;
  }
  else if(k1*b>k2*d){
    cout<<k2*d<<endl;
  }
  else {
    cout<<k1*b<<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)*b;
  int Y = (n/c + n%c)*d;
  cout << min(X, Y) << endl;
}