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

package qualification;


import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class Task2 {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new FileInputStream("task21.txt"));
        int T = scanner.nextInt();
        for (int i = 0; i < T; i++) {
            int N = scanner.nextInt();
            int S = scanner.nextInt();
            int p = scanner.nextInt();
            int[] t = new int[N];
            for (int j = 0; j < N; j++) {
                t[j] = scanner.nextInt();
            }
            int noProbMin = Math.max(p * 3 - 2, p);
            int surpriseMin = Math.max(p * 3 - 4, p);
            int noProbCount = 0;
            int surpriseCount = 0;
            for (int googler : t) {
                if (googler >= noProbMin) {
                    noProbCount++;
                }
                if (googler < noProbMin && googler >= surpriseMin) {
                    surpriseCount++;
                }
            }
            surpriseCount = Math.min(surpriseCount, S);
            System.out.println("Case #" + (i + 1) + ": " + (noProbCount + surpriseCount));
        }
    }
}
