using
System;
using
System.Collections.Generic;
class
GFG{
static
void
FindBill(
int
X,
int
Y,
int
Z,
int
N,
int
a,
int
b)
{
int
minimum_bill = 10000000;
for
(
int
orders_C = 0; orders_C <= N; orders_C++) {
if
(a < orders_C || b < orders_C)
break
;
int
maxorders_A = (a - orders_C) / 2;
int
maxorders_B = (b - orders_C) / 3;
int
orders_A = 0;
int
orders_B = 0;
if
((maxorders_A + maxorders_B + orders_C) < N) {
continue
;
}
if
(X < Y) {
orders_A = Math.Min(maxorders_A, N - orders_C);
orders_B = N - orders_C - orders_A;
}
else
{
orders_B = Math.Min(maxorders_B, N - orders_C);
orders_A = N - orders_C - orders_B;
}
int
bill = (X * orders_A)
+ (Y * orders_B)
+ (Z * orders_C);
minimum_bill = Math.Min(bill, minimum_bill);
}
if
(minimum_bill == 10000000)
minimum_bill = 0;
Console.Write(minimum_bill);
}
public
static
void
Main()
{
int
X = 300, Y = 150, Z = 200, N = 5, a = 6, b = 4;
/// Function Call
FindBill(X, Y, Z, N, a, b);
}
}