SHARE
TWEET

Bday gifts

Douma37 May 19th, 2019 (edited) 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.math.*;
  3. import java.security.*;
  4. import java.text.*;
  5. import java.util.*;
  6. import java.util.concurrent.*;
  7. import java.util.regex.*;
  8.  
  9. public class Solution {
  10.  
  11.     // Complete the taumBday function below.
  12.     static long taumBday(int b, int w, int bc, int wc, int z) {
  13.         if (bc + z < wc) {
  14.             return b * bc + w * (bc + z);
  15.         } else if (wc + z < bc) {
  16.             return w * wc + b * (wc + z);
  17.         } else {
  18.             return w * wc + b * bc;
  19.         }
  20.     }
  21.  
  22.     private static final Scanner scanner = new Scanner(System.in);
  23.  
  24.     public static void main(String[] args) throws IOException {
  25.         BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
  26.  
  27.         int t = scanner.nextInt();
  28.         scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
  29.  
  30.         for (int tItr = 0; tItr < t; tItr++) {
  31.             String[] bw = scanner.nextLine().split(" ");
  32.  
  33.             int b = Integer.parseInt(bw[0]);
  34.  
  35.             int w = Integer.parseInt(bw[1]);
  36.  
  37.             String[] bcWcz = scanner.nextLine().split(" ");
  38.  
  39.             int bc = Integer.parseInt(bcWcz[0]);
  40.  
  41.             int wc = Integer.parseInt(bcWcz[1]);
  42.  
  43.             int z = Integer.parseInt(bcWcz[2]);
  44.  
  45.             long result = taumBday(b, w, bc, wc, z);
  46.  
  47.             bufferedWriter.write(String.valueOf(result));
  48.             bufferedWriter.newLine();
  49.         }
  50.  
  51.         bufferedWriter.close();
  52.  
  53.         scanner.close();
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top