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.util.ArrayList;
import java.util.Scanner;


public class GooglerDancer {

	private int caseNumber;
	private int numberOfGooglers;
	private int numberOfSuprisingTriplets;
	private int minimumBestScoreP;
	private ArrayList<Integer> list;


	public GooglerDancer(int caseNumber,String data) {

		this.caseNumber=caseNumber;
		Scanner s=new Scanner(data);
		this.numberOfGooglers=s.nextInt();
		this.numberOfSuprisingTriplets=s.nextInt();
		this.minimumBestScoreP=s.nextInt();
		list=new ArrayList<Integer>();
		while(s.hasNextInt()){
			list.add(s.nextInt());
		}
	}


	public void process() {
		int count =0;
		
		if(numberOfGooglers>0){
		/////
			if(minimumBestScoreP>0){
		for(int i=0;i<numberOfGooglers;i++){
			if(list.get(i)>0)
			{
			if((Integer)(list.get(i)/minimumBestScoreP)>=3){
				count++;
			}
			else{
				if((Integer)(minimumBestScoreP-(list.get(i)-minimumBestScoreP)/2)==1){
					count++;
				}
				else{
					if((Integer)(minimumBestScoreP-(list.get(i)-minimumBestScoreP)/2)==2 && numberOfSuprisingTriplets>0){
						count++;
						numberOfSuprisingTriplets--;
					}
				}
			}
		}
		}
		////////////
			}else{
				count=numberOfGooglers;
			}
		}
		System.out.println("Case #"+caseNumber+": "+count);

	}

}
