-
Notifications
You must be signed in to change notification settings - Fork 694
/
Copy pathSolution.java
33 lines (27 loc) · 1.19 KB
/
Solution.java
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
26
27
28
29
30
31
32
33
//Problem: https://www.hackerrank.com/challenges/taum-and-bday
//Java 8
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 a0 = 0; a0 < t; a0++){
long blackGifts = in.nextLong();
long whiteGifts = in.nextLong();
long blackPrice = in.nextLong();
long whitePrice = in.nextLong();
long conversionPrice = in.nextLong();
//End of Given Code//
//Calculate white->black and choose max between it and black
long minBlackPrice = Math.min(blackPrice, whitePrice + conversionPrice);
//Calculate black->white and choose max between it and white
long minWhitePrice = Math.min(whitePrice, blackPrice + conversionPrice);
//Multiple the price for each one by the number of gifts we need
System.out.println((minBlackPrice * blackGifts) + (minWhitePrice * whiteGifts));
}
}
}