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<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int ans=0;
  for(int i=0;1;i++){
    for(int j=0;1;j++){
      if(j*c+i*a>=n){
	if(ans==0) ans=i*b+j*d;
	else if(ans>i*b+j*d) ans=i*b+j*d;
	break;
      }
    }
    if(i*a>n) break;
  }
  cout<<ans<<endl;
  return 0;
}

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

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

  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;
	}
    }
  else if(n % c == 0)
    {
      cout << (n/c)*d << endl;
    }
  else if(n % a == 0)
    {
      cout << (n/a)*b << endl;
    }
  else
    {
      num1= (n/a)+1;
      num2= (n/c)+1;
      if(num1*b < num2*d)
	{
	  cout << num1*b << endl;
	}
      else
	{
	  cout << num2*d << endl;
	}
    }
}

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

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

C++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	cout << min((n % a ? n / a + 1 : n / a) * b, (n % c ? n / c + 1 : n / c) * d) << endl;
}

C++: #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  assert(0);
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;

  int mx = 0;
  for(int i=0;i<n;i++){
    int j = i;
    while(j < n && A[j] == 1) j++;
    Max(mx,j - i);
  }

  cout<<mx+1<<endl;

  
  return 0;
}

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

int main(void){
    int n, a, b, c, d;
    int sum1 = 0, sum2 = 0;
    int kane1 = 0, kane2 = 0;

    cin >> n >> a >> b >> c >> d;
    
    while(sum1 < n){
        sum1 += a;
        kane1 += b; 
    }
    while(sum2 < n){
        sum2 += c;
        kane2 += d;
    }
    if(kane1 < kane2){
        cout << kane1 << endl;
    }else{
        cout << kane2 << endl;
    }
}

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

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

}

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

int main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	int ans_x = 0; int ans_y = 0; int n_x = n; int n_y = n;
	while (n_x > 0) { n_x = n_x - a; ans_x = ans_x + b; }
	while (n_y > 0) { n_y = n_y - c; ans_y = ans_y + d; }
	cout << (ans_x > ans_y ? ans_y : ans_x) << endl;
	return 0;
}

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

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int x,y;
  if(n%a!=0){
    x=((n/a+1)*b);
  }else
    x=n/a*b;
  if(n%c!=0){
    y=((n/c+1)*d);
  }else
    y=n/c*d;

  if(x>y)
    cout<<y<<endl;
  else
    cout<<x<<endl;
  return 0;
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int n, a, b, c, d;
	int ans;
	cin >> n >> a >> b >> c >> d;
	for (int i = 0;i<=n; i++){
		if (i*a >= n){
			ans = i*b;
			break;
		}
	}
	for (int j = 0; j <= n; j++){
		if (j*c >= n){
			if (ans > j*d){
				ans = j*d;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

C++: #include <iostream>

using namespace std;

int main()
{
	int  n, a, b, c, d, a1, a2;
	cin >> n >> a >> b >> c >> d;
	a1 = b * ((n / a) + 1);
	if (n%a == 0)
	{
		a1 -= b;
	}
	a2 = d * ((n / c) + 1);
	if (n%c == 0)
	{
		a2 -= d;
	}
	if (a1 < a2)
	{
		cout << a1 << endl;
	}
	else
		cout << a2 << 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,y;
	int valueX;
	int valueY;

	if(n%a == 0){
		x = n/a;	
	}
	else{
		x = n/a + 1;
	}

	if(n%c == 0){
		y = n/c;
	}
	else{
		y = n/c +1;
	}

	valueX = x*b;
	valueY = y*d;

	if(valueX <= valueY){
		cout << valueX << endl;
	}
	else{
		cout << valueY << endl;
	}



	return 0;
}