UVA 12015 – Google is Feeling Lucky

Simple!

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

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

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

    ArrayList<String> ans;
    int N = sc.nextInt();
    for (int i = 1; i <= N; i++) {
      int max = -1;
      ans = new ArrayList<String>();
      for (int j = 0; j < 10; j++) {
        String tmp = sc.next();
        int val = sc.nextInt();
        if (val > max) {
          ans.clear();
          ans.add(tmp);
          max = val;
        } else if (val == max) {
          ans.add(tmp);
        }
      }
      out.println("Case #" + i + ":");
      for (String t : ans) {
        out.println(t);
      }
    }

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

Leave a Reply

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