package dancinggooglers;

import java.io.File;
import java.util.Scanner;

public class DanceScoreCalculator {


    public static void main(String[] args) {
        if(args.length <= 0 || args[0] == null) {
            System.out.println("You must enter a file to read");
            System.out.println("Usage: blah <filename>");
            System.exit(0);
        }

        File argFile = new File(args[0]);
        try {
            Scanner googleSpeakScanner = new Scanner(argFile);
            String firstLine = googleSpeakScanner.nextLine();
            Integer linesToScan = new Integer(firstLine);
            for(int i = 1; i <= linesToScan; i++) {
                String googleDancerLine = googleSpeakScanner.nextLine();
                DanceScoreCase danceCase = new DanceScoreCase(googleDancerLine);
                System.out.println(String.format("Case #%d: %d", i, danceCase.maxDancersThatCouldPass()));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

import java.io.*;
import java.util.*;

public class GoogleCount{
	
	public GoogleCount(String line, int i, BufferedWriter out){
		int count=0;
		try {
//			ArrayList<Goods> gooda = new ArrayList();
//			TreeSet<Integer> goods = new TreeSet();
			StringTokenizer token = new StringTokenizer(line);
			out.write("Case #"+Integer.toString(i)+": ");
			String str = null;
			Goods cur;
			int countS=0, countG=0;
	  		while (token.hasMoreTokens()){
				str = token.nextToken();
				int totG=Integer.parseInt(str);

				str = token.nextToken();
				int totS=Integer.parseInt(str);

				str = token.nextToken();
				int best=Integer.parseInt(str);

				int curr,temp;
				while (token.hasMoreTokens() && count<totG){
					str = token.nextToken();
					curr=Integer.parseInt(str);
					
					if(curr>=best){
						if (curr-best>=((best-1)*2)){

							countG++;
						}
						else if(curr-best>=((best-2)*2) && countS<totS){

							countS++;
							countG++;
						}
					}
					count++;
				}
			}
			out.write(Integer.toString(countG));
			System.out.print("\n");
			out.write("\n");
		}
		catch (IOException ex){
		      ex.printStackTrace();	    		
		}	
	}		
}
