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();
        }
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problem.b.dancing.with.the.googlers;

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

/**
 *
 * @author Park
 */
public class ProblemBDancingWithTheGooglers {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        PrintStream out = new PrintStream(new File("/Users/Park/Desktop/output.txt"));
        Scanner in = new Scanner(new File("/Users/Park/Desktop/B-large.in"));
        int testCase = Integer.parseInt(in.next());
        for (int n = 0; n < testCase; n++) {
            int count = 0;
            int googlers = Integer.parseInt(in.next());
            int surprising = Integer.parseInt(in.next());
            int wantScores = Integer.parseInt(in.next());
            for (int g = 0; g < googlers; g++) {
                int scores = Integer.parseInt(in.next());
                if (scores - (wantScores * 3) >= -2) {
                    count++;
                } else if ((surprising > 0) && (((scores - (wantScores * 3) == -4)&&scores>=2) || ((scores - (wantScores * 3) == -3)&&scores>=3))) {
                    surprising--;
                    count++;
                }
            }
            out.println("Case #" + (n + 1) + ": " + count);
            System.out.println("Case #" + (n + 1) + ": " + count);
        }
        in.close();
        out.close();
    }
}
