Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	p := nextInt()

	priceA := a * p
	priceB := 0
	if p <= c {
		priceB = b
	} else {
		priceB = b + (p-c)*d
	}
	fmt.Println(min(priceA, priceB))
}

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

int main(){
	/*
	int a,b,c,d,e;

	cin >> a >> b >> c >> d >> e;

	int x;

	if(a > 0){
		x = e*(b-a);
	}
	if(a == 0){
		x = e*b + d;
	}
	if(a < 0){
		x = -c*a + e*b + d;
	}

	cout << x <<endl;
	*/

	/*
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	int m,n;
	int x = a + b + c + d + e + f;


	
	if(e<f)
	{
		x = x - e;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	else
	{
		x = x - f;
		if(a<b)
		{
			if(a<c)
			{
				if(a<d)
				{
					cout << x-a << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
		else
		{
			if(b<c)
			{
				if(b<d)
				{
					cout << x-b << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
			else
			{
					if(c<d)
				{
					cout << x-c << endl;
				}
				else
				{
					cout << x-d << endl;
				}
			}
		}
	}
	*/
/*
	int n;
	cin >> n;
	int a;
	cin >> a;
	int max = a,min = a;
	int i = 1;
	while(i<n){
		cin >> a;
		if(a > max){
			max = a;
		}
		if(a < min){
			min = a;
		}
		i++;
	}
	cout << max << endl << min << endl;
	*/
	/*
	string s;
	cin >> s;
	int j,o,i;
	for(int i;i < s.size;i++){
		
	}
	*/
	/*
	int n;
	cin >> n;
	int A;
	int X[100000];
	int n=0;
	for(int i=0;i<n;i++){
		cin >> A;
		
	}
	*/

	int a,b,c,d,p;
	cin >> a >> b >> c >> d >> p;
	int X,Y=b;

	X = a*p;
	
	if(p>c){
		Y += d*(p-c);
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d,p,priceX=0,priceY=0;
    cin>>a>>b>>c>>d>>p;
    //X社
    priceX=a*p;
    //Y社
    if (c>=p) {
        priceY=b;
    } else {
        priceY=(p-c)*d+b;
    }
    cout<<min(priceX,priceY)<<endl;
}

C++: #include <iostream>
using namespace std;
int main(void)
{
	int a,b,c,d,e,f,g,h;
	cin>>a>>b>>c>>d>>e;
	f=a*e;
	if (e<c)
	{
		g=b;
	}
	else if(e>c)
	{
		g=b+(e-c)*d;
	}
	if (g<f)
	{
		cout<<g<<endl;
	}
	else if (g>f)
	{
		cout<<f<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,p;
  cin >> a >> b >> c >> d >> p;
  cout << min(p*a,b+(p-min(c,p))*d) << endl;
  return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
	int A,B,C,D,P,S=0,T=0;
	cin >> A >> B >> C >> D>> P;
	if (P<=C:S<=T){
	S=A*P;
	cout<< S << endl;
	}
	else {
		T=B+(P-C)*D;
		cout<< T << endl;
	}
	// your code goes here
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	
	int a,b,c,d,p,x=0,y=0;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>p;

	x=p*a;
	if(p<=c){
		y=b;
	}
	else if(p>=c){
		y=b+d*(p-c);
	}
	if(x>y){swap(x,y);}
	cout<<x<<endl;

return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int x = max(e - c, 0) * d + b;
	cout << min(a * e, x) << endl;
	return 0;
}

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

int main(void){

  int x,ybas,ylim,yvol,us;
  int resx,resy;

  cin >> x >> ybas >> ylim >> yvol >> us;

  resx = us * x;
  resy = ybas;
  if(ylim < us) resy += (us - ylim) * yvol;

  if(resx < resy) cout << resx << endl;
  else cout << resy << endl;

  return 0;
}

C++: /*
 * 0608.cc: Water Rate
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int ta = a * p;

  int tb = b;
  if (p > c) tb += (p - c) * d;

  printf("%d\n", (ta < tb) ? ta : tb);
  return 0;
}

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

int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	int x, y;
	x = p * a;
	if (p <= c) {
		y = b;
	}
	else {
		y = b + ((p - c) * d);
	}
	if (y > x) {
		cout << x << endl;
	}
	else {
		cout << y << endl;;
	}
	return 0;
}

C++: #include  <iostream>

using namespace std;

int main()
{
	int x, y1, y2, y3, joi;
	int resx, resy;
	
	cin >> x;
	cin >> y1;
	cin >> y2;
	cin >> y3;
	cin >> joi;
	
	resx = x * joi;
	resy = y1 + (joi > y2 ? y2 - joi : 0) * y3;
	
	cout << (resx < resy ? resx : resy) << endl;
}

C++: #include<iostream>
using namespace std;
int main() {
	int A, B, C, D, P, X, Y;
	cin >> A >> B >> C >> D >> P;
	X = A*P;
	Y = (P <= C) ? B : (P - C)*D+B;
	cout << ((X < Y) ? X : Y) << endl;
	return 0;
}

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

int main() {
	int a, b, c, d, p; cin >> a >> b >> c >> d >> p;
	int ans_x = a * p; int ans_y = b;
	if (p > c) ans_y = ans_y + d * (p - c);
	cout << (ans_x > ans_y ? ans_y : ans_x) << endl;
	return 0;
}

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

int main(void){

  int x,ybas,ylim,yvol,us;
  int resx,resy;

  cin >> x >>ybas >> ylim >> yvol >> us;

  resx = us * x;
  resy = ybas;
  resy += (ylim < us)? (us - ylim) * yvol : 0;

  if(resx < resy) cout << resx << endl;
  else cout << resy << endl;
  
  return 0;
}

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

int a, b, c, d, p;
int x, y; 

int main()
{  
  cin >> a >> b >> c >> d >> p;
  x = p * a;
  y = b;
  if (p - c > 0) {
    y += (p - c) * d;
  }
  if (x > y){
    x = y;
  }
  cout << x << endl;
  return 0;
}

C++: #include<stdio.h>
int main()
{
int A,B,C,D,P;
scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
A=P*A;
if(C<P){
C=P-C;
D=D*C;
B=B+D;
}
if(A<B){
printf("%d\n",A);
}else if(B<=A){
printf("%d\n",B);
}
return(0);
}

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

using namespace std;

int main(){

  int a,b,c,d,p;
  int x,y;
  
  cin>>a>>b>>c>>d>>p;

  x=a*p;
  
  if(c>=p)
	y=b;
  else
	y=b+d*p;

  cout<<min(x,y)<<endl;

}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll A, B, C, D, P;
  cin >> A >> B >> C >> D >> P;
  cout << min(A * P, max(B, B + D * (P - C))) << "\n";
  return 0;
}

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

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

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

	if (p <= c){
		printf("%d\n", min(p * a, b));
	}
	else {
		printf("%d\n", min(p * a, b + (p - c) * d));
	}

	return (0);
}

C++: #include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
    int a,b,c,d,p,x,y;
    cin>>a>>b>>c>>d>>p;
    x=p*a;
    if(p>=c){
        y=b+(p-c)*d;
    }
    else{
        y=b;
    }
    if(x>y){
        cout<<y<<endl;
    }
    else{
        cout<<x<<endl;
    }
}