UVA 12157 – Tariff Plan

I had initially accidentally written “Case #1” instead of “Case 1” :[

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 
 * @author Sanchit M. Bhatnagar
 * @see http://uhunt.felix-halim.net/id/74004
 * 
 */
public class P12157 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int T = sc.nextInt();
    for (int zz = 1; zz <= T; zz++) {
      int N = sc.nextInt();
      int mileCost = 0;
      int juiceCost = 0;
      for (int i = 0; i < N; i++) {
        int talkTime = sc.nextInt();
        mileCost += (int) Math.ceil(talkTime / 30.0) * 10;
        if (talkTime % 30 == 0)
          mileCost += 10;
        juiceCost += (int) Math.ceil(talkTime / 60.0) * 15;
        if (talkTime % 60 == 0)
          juiceCost += 15;
      }
      out.print("Case " + zz + ": ");
      if (mileCost < juiceCost) {
        out.println("Mile " + mileCost);
      } else if (juiceCost < mileCost) {
        out.println("Juice " + juiceCost);
      } else {
        out.println("Mile Juice " + mileCost);
      }
    }

    out.close();
    sc.close();
  }
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.