-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathTaumandB'day.java
More file actions
25 lines (24 loc) · 670 Bytes
/
Copy pathTaumandB'day.java
File metadata and controls
25 lines (24 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
public class Solution {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t--!=0){
long x = sc.nextLong();
long y = sc.nextLong();
long a = sc.nextLong();
long b = sc.nextLong();
long c = sc.nextLong();
long cost = x*a + y*b;
if(a>b){
if(b+c<a)
cost = x*(b+c) + y*b;
}
else if(a<b){
if(a+c<b)
cost = x*a + y*(a+c);
}
System.out.println(cost);
}
}
}