import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class TariffPlan {
public static void main(String[] args) throws Exception {
Reader.init(System.in);
//Reader.init(new FileInputStream(new File("input.in")));
int noOfTestCases = Reader.nextInt();
for(int i = 1; i <= noOfTestCases; i++) {
int noOfCalls = Reader.nextInt();
int mileTarifCost = 0;
int juiceTarifCost = 0;
int tempSeconds;
for(int j = 0; j < noOfCalls; j++) {
tempSeconds = Reader.nextInt();
//System.out.println("DEBUG: seconds / 30: " + ((tempSeconds/30) + 1));
mileTarifCost += (10 * (tempSeconds/30 + 1));
juiceTarifCost += (15 * (tempSeconds/60 + 1));
}
if(mileTarifCost < juiceTarifCost) {
System.out.println("Case " + i + ": Mile " + mileTarifCost);
} else if(mileTarifCost > juiceTarifCost) {
System.out.println("Case " + i + ": Juice " + juiceTarifCost);
} else {
System.out.println("Case " + i + ": Mile Juice "+ mileTarifCost);
}
}
}
}
/** Class for buffered reading int and double values */
/** http://www.cpe.ku.ac.th/~jim/java-io.html */
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
/** call this method to initialize reader for InputStream */
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
/** get next word */
static String next() throws IOException {
while ( ! tokenizer.hasMoreTokens() ) {
//TODO add check for eof if necessary
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt( next() );
}
static double nextDouble() throws IOException {
return Double.parseDouble( next() );
}
}
10/08/2013
12157 - Tariff Plan - Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment