import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int i=0;i<t;i++)
{
int black = in.nextInt();
int white = in.nextInt();
int cost_black = in.nextInt();
int cost_white = in.nextInt();
int change_b_w = in.nextInt();
long temp1=cost_black;
long temp2=cost_white;
if(cost_black>=cost_white)
temp1=cost_black;
else
temp2=cost_white;
if(temp1+change_b_w<temp2)
temp2=temp1+change_b_w;
if(temp2+change_b_w<temp1)
temp1=temp2+change_b_w;
long cost=black*temp1+white*temp2;
System.out.println(cost);
}
}
}
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int i=0;i<t;i++)
{
int black = in.nextInt();
int white = in.nextInt();
int cost_black = in.nextInt();
int cost_white = in.nextInt();
int change_b_w = in.nextInt();
long temp1=cost_black;
long temp2=cost_white;
if(cost_black>=cost_white)
temp1=cost_black;
else
temp2=cost_white;
if(temp1+change_b_w<temp2)
temp2=temp1+change_b_w;
if(temp2+change_b_w<temp1)
temp1=temp2+change_b_w;
long cost=black*temp1+white*temp2;
System.out.println(cost);
}
}
}
No comments:
Post a Comment